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.
- package/README.md +19 -11
- package/README.zh-CN.md +10 -8
- package/node_modules/@insforge/sdk/LICENSE +201 -201
- package/node_modules/@insforge/sdk/README.md +326 -259
- package/node_modules/@insforge/sdk/dist/index.d.mts +377 -182
- package/node_modules/@insforge/sdk/dist/index.d.ts +377 -182
- package/node_modules/@insforge/sdk/dist/index.js +1172 -677
- package/node_modules/@insforge/sdk/dist/index.js.map +1 -1
- package/node_modules/@insforge/sdk/dist/index.mjs +1171 -677
- package/node_modules/@insforge/sdk/dist/index.mjs.map +1 -1
- package/node_modules/@insforge/sdk/package.json +68 -68
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts +1120 -43
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js +179 -5
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts +25 -25
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js +2 -2
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts +197 -51
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js +87 -23
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts +32 -3
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js +21 -3
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts +380 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js +74 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts +13 -13
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts +735 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js +209 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts +37 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js +25 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts +5 -1
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js +34 -4
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts +186 -6
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js +21 -2
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts +5 -5
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts +24 -18
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/index.js +24 -18
- package/node_modules/@insforge/shared-schemas/dist/index.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts +43 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js +11 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts +229 -172
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js +27 -7
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts +51 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js +31 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts +31 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js +12 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts +39 -20
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js +5 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts +12 -4
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js +6 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts +287 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js +81 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts +77 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js +36 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts +113 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js +31 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts +31 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js +13 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts +27 -2
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js +9 -1
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts +17 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js +6 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/package.json +2 -1
- package/package.json +2 -2
- package/src/commands/status.js +22 -5
- package/src/commands/sync.js +100 -197
- package/src/commands/uninstall.js +0 -11
- package/src/lib/diagnostics.js +34 -9
- package/src/lib/doctor.js +24 -15
- package/src/lib/insforge-client.js +13 -9
- package/src/lib/integrations/context.js +0 -6
- package/src/lib/integrations/index.js +0 -2
- package/src/lib/openclaw-session-plugin.js +48 -138
- package/src/lib/openclaw-usage-ledger.js +237 -0
- package/src/lib/opencode-sqlite.js +113 -0
- package/src/lib/opencode-usage-audit.js +3 -2
- package/src/lib/rollout.js +229 -153
- package/src/lib/vibeusage-api.js +2 -2
- package/src/lib/integrations/openclaw-legacy.js +0 -123
- package/src/lib/openclaw-hook.js +0 -420
|
@@ -1,259 +1,326 @@
|
|
|
1
|
-
# insforge-sdk-js
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@insforge/sdk)
|
|
4
|
-
[](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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//
|
|
104
|
-
const { data
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
1
|
+
# insforge-sdk-js
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@insforge/sdk)
|
|
4
|
+
[](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
|