@insforge/sdk 1.3.1 → 1.3.2-razorpay.1
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 +74 -22
- package/SDK-REFERENCE.md +169 -65
- package/dist/{client-DTNmGqHB.d.mts → client-Co8KxT-n.d.mts} +33 -6
- package/dist/{client-DTNmGqHB.d.ts → client-Co8KxT-n.d.ts} +33 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +126 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -8
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.d.mts +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.js +126 -8
- package/dist/ssr.js.map +1 -1
- package/dist/ssr.mjs +126 -8
- package/dist/ssr.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -206,13 +206,16 @@ const { data, error } = await insforge.functions.invoke("my-function", {
|
|
|
206
206
|
|
|
207
207
|
```javascript
|
|
208
208
|
// Create and redirect to a Stripe Checkout Session
|
|
209
|
-
const { data, error } = await insforge.payments.createCheckoutSession(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
209
|
+
const { data, error } = await insforge.payments.stripe.createCheckoutSession(
|
|
210
|
+
"test",
|
|
211
|
+
{
|
|
212
|
+
mode: "payment",
|
|
213
|
+
lineItems: [{ priceId: "price_123", quantity: 1 }],
|
|
214
|
+
successUrl: `${window.location.origin}/success`,
|
|
215
|
+
cancelUrl: `${window.location.origin}/pricing`,
|
|
216
|
+
idempotencyKey: "cart_123",
|
|
217
|
+
},
|
|
218
|
+
);
|
|
216
219
|
|
|
217
220
|
if (!error && data?.checkoutSession.url) {
|
|
218
221
|
window.location.assign(data.checkoutSession.url);
|
|
@@ -220,10 +223,10 @@ if (!error && data?.checkoutSession.url) {
|
|
|
220
223
|
|
|
221
224
|
// Create a subscription checkout for an app billing subject
|
|
222
225
|
const { data: subscriptionCheckout } =
|
|
223
|
-
await insforge.payments.createCheckoutSession("test", {
|
|
226
|
+
await insforge.payments.stripe.createCheckoutSession("test", {
|
|
224
227
|
mode: "subscription",
|
|
225
228
|
subject: { type: "team", id: "team_123" },
|
|
226
|
-
lineItems: [{
|
|
229
|
+
lineItems: [{ priceId: "price_monthly_123", quantity: 1 }],
|
|
227
230
|
successUrl: `${window.location.origin}/billing/success`,
|
|
228
231
|
cancelUrl: `${window.location.origin}/billing`,
|
|
229
232
|
});
|
|
@@ -233,33 +236,82 @@ if (subscriptionCheckout?.checkoutSession.url) {
|
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
// Let an authenticated customer manage their subscription in Stripe Billing Portal
|
|
236
|
-
const { data: portal } =
|
|
237
|
-
"test",
|
|
238
|
-
{
|
|
239
|
+
const { data: portal } =
|
|
240
|
+
await insforge.payments.stripe.createCustomerPortalSession("test", {
|
|
239
241
|
subject: { type: "team", id: "team_123" },
|
|
240
242
|
returnUrl: `${window.location.origin}/billing`,
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
+
});
|
|
243
244
|
|
|
244
245
|
if (portal?.customerPortalSession.url) {
|
|
245
246
|
window.location.assign(portal.customerPortalSession.url);
|
|
246
247
|
}
|
|
248
|
+
|
|
249
|
+
// Create a Razorpay order, then pass checkoutOptions to Razorpay Checkout.js
|
|
250
|
+
const { data: order } = await insforge.payments.razorpay.createOrder("test", {
|
|
251
|
+
amount: 200000,
|
|
252
|
+
currency: "INR",
|
|
253
|
+
subject: { type: "team", id: "team_123" },
|
|
254
|
+
customerEmail: "ada@example.com",
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
if (order) {
|
|
258
|
+
const checkout = new Razorpay({
|
|
259
|
+
...order.checkoutOptions,
|
|
260
|
+
handler: async (response) => {
|
|
261
|
+
await insforge.payments.razorpay.verifyOrder("test", {
|
|
262
|
+
orderId: response.razorpay_order_id,
|
|
263
|
+
paymentId: response.razorpay_payment_id,
|
|
264
|
+
signature: response.razorpay_signature,
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
checkout.open();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Create a Razorpay subscription checkout for an app billing subject
|
|
272
|
+
const { data: subscription } =
|
|
273
|
+
await insforge.payments.razorpay.createSubscription("test", {
|
|
274
|
+
planId: "plan_123",
|
|
275
|
+
totalCount: 12,
|
|
276
|
+
subject: { type: "team", id: "team_123" },
|
|
277
|
+
});
|
|
247
278
|
```
|
|
248
279
|
|
|
249
280
|
### AI Integration
|
|
250
281
|
|
|
282
|
+
AI methods return an OpenAI-like response object directly (not the `{ data, error }` envelope used by the other modules) and throw on failure.
|
|
283
|
+
|
|
251
284
|
```javascript
|
|
252
|
-
//
|
|
253
|
-
const
|
|
254
|
-
model: "
|
|
255
|
-
|
|
285
|
+
// Chat completion
|
|
286
|
+
const completion = await insforge.ai.chat.completions.create({
|
|
287
|
+
model: "anthropic/claude-3.5-haiku",
|
|
288
|
+
messages: [{ role: "user", content: "Write a hello world program" }],
|
|
289
|
+
});
|
|
290
|
+
console.log(completion.choices[0].message.content);
|
|
291
|
+
|
|
292
|
+
// Streaming chat — returns an async iterable of chunks
|
|
293
|
+
const stream = await insforge.ai.chat.completions.create({
|
|
294
|
+
model: "anthropic/claude-3.5-haiku",
|
|
295
|
+
messages: [{ role: "user", content: "Tell me a story" }],
|
|
296
|
+
stream: true,
|
|
297
|
+
});
|
|
298
|
+
for await (const chunk of stream) {
|
|
299
|
+
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Generate an image — returns base64-encoded image data
|
|
303
|
+
const image = await insforge.ai.images.generate({
|
|
304
|
+
model: "google/gemini-3-pro-image-preview",
|
|
305
|
+
prompt: "A sunset over mountains",
|
|
256
306
|
});
|
|
307
|
+
const base64Png = image.data[0].b64_json;
|
|
257
308
|
|
|
258
|
-
//
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
309
|
+
// Create embeddings
|
|
310
|
+
const embeddings = await insforge.ai.embeddings.create({
|
|
311
|
+
model: "openai/text-embedding-3-small",
|
|
312
|
+
input: "Hello world",
|
|
262
313
|
});
|
|
314
|
+
console.log(embeddings.data[0].embedding); // number[]
|
|
263
315
|
```
|
|
264
316
|
|
|
265
317
|
## Documentation
|
package/SDK-REFERENCE.md
CHANGED
|
@@ -382,18 +382,21 @@ await insforge.auth.resetPassword({
|
|
|
382
382
|
|
|
383
383
|
## Payments Methods
|
|
384
384
|
|
|
385
|
-
Payments methods are intended for generated app frontends. They call runtime-safe backend routes using the current user token or anon key. Admin-only
|
|
385
|
+
Payments methods are provider-scoped and intended for generated app frontends. They call runtime-safe backend routes using the current user token or anon key. Admin-only key, catalog, sync, transaction, and webhook configuration APIs are intentionally not exposed through this frontend SDK surface.
|
|
386
386
|
|
|
387
|
-
### `createCheckoutSession()`
|
|
387
|
+
### `stripe.createCheckoutSession()`
|
|
388
388
|
|
|
389
389
|
```javascript
|
|
390
|
-
const { data, error } = await insforge.payments.createCheckoutSession(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
const { data, error } = await insforge.payments.stripe.createCheckoutSession(
|
|
391
|
+
"test",
|
|
392
|
+
{
|
|
393
|
+
mode: "payment",
|
|
394
|
+
lineItems: [{ priceId: "price_123", quantity: 1 }],
|
|
395
|
+
successUrl: "https://example.com/success",
|
|
396
|
+
cancelUrl: "https://example.com/pricing",
|
|
397
|
+
idempotencyKey: "cart_123", // optional, recommended for retry-safe checkout creation
|
|
398
|
+
},
|
|
399
|
+
);
|
|
397
400
|
|
|
398
401
|
if (!error && data?.checkoutSession.url) {
|
|
399
402
|
window.location.assign(data.checkoutSession.url);
|
|
@@ -403,25 +406,23 @@ if (!error && data?.checkoutSession.url) {
|
|
|
403
406
|
For one-time payments, `subject` is optional. For subscription checkout, `subject` is required because subscriptions represent ongoing entitlement for an app-defined billing owner.
|
|
404
407
|
|
|
405
408
|
```javascript
|
|
406
|
-
await insforge.payments.createCheckoutSession("test", {
|
|
409
|
+
await insforge.payments.stripe.createCheckoutSession("test", {
|
|
407
410
|
mode: "subscription",
|
|
408
411
|
subject: { type: "team", id: "team_123" },
|
|
409
|
-
lineItems: [{
|
|
412
|
+
lineItems: [{ priceId: "price_monthly_123", quantity: 1 }],
|
|
410
413
|
successUrl: "https://example.com/billing/success",
|
|
411
414
|
cancelUrl: "https://example.com/billing",
|
|
412
415
|
});
|
|
413
416
|
```
|
|
414
417
|
|
|
415
|
-
### `createCustomerPortalSession()`
|
|
418
|
+
### `stripe.createCustomerPortalSession()`
|
|
416
419
|
|
|
417
420
|
```javascript
|
|
418
|
-
const { data, error } =
|
|
419
|
-
"test",
|
|
420
|
-
{
|
|
421
|
+
const { data, error } =
|
|
422
|
+
await insforge.payments.stripe.createCustomerPortalSession("test", {
|
|
421
423
|
subject: { type: "team", id: "team_123" },
|
|
422
424
|
returnUrl: "https://example.com/billing",
|
|
423
|
-
}
|
|
424
|
-
);
|
|
425
|
+
});
|
|
425
426
|
|
|
426
427
|
if (!error && data?.customerPortalSession.url) {
|
|
427
428
|
window.location.assign(data.customerPortalSession.url);
|
|
@@ -430,6 +431,83 @@ if (!error && data?.customerPortalSession.url) {
|
|
|
430
431
|
|
|
431
432
|
Customer portal sessions require an authenticated user and an existing Stripe customer mapping for the billing subject.
|
|
432
433
|
|
|
434
|
+
### `razorpay.createOrder()`
|
|
435
|
+
|
|
436
|
+
Razorpay uses Checkout.js instead of a hosted redirect URL. Create an order through InsForge, pass `checkoutOptions` into Razorpay Checkout.js, then verify the signed payment response.
|
|
437
|
+
|
|
438
|
+
```javascript
|
|
439
|
+
const { data, error } = await insforge.payments.razorpay.createOrder("test", {
|
|
440
|
+
amount: 200000,
|
|
441
|
+
currency: "INR",
|
|
442
|
+
receipt: "cart_123",
|
|
443
|
+
subject: { type: "team", id: "team_123" },
|
|
444
|
+
customerName: "Ada Lovelace",
|
|
445
|
+
customerEmail: "ada@example.com",
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
if (!error && data) {
|
|
449
|
+
const checkout = new Razorpay({
|
|
450
|
+
...data.checkoutOptions,
|
|
451
|
+
handler: async (response) => {
|
|
452
|
+
await insforge.payments.razorpay.verifyOrder("test", {
|
|
453
|
+
orderId: response.razorpay_order_id,
|
|
454
|
+
paymentId: response.razorpay_payment_id,
|
|
455
|
+
signature: response.razorpay_signature,
|
|
456
|
+
});
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
checkout.open();
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### `razorpay.createSubscription()`
|
|
465
|
+
|
|
466
|
+
```javascript
|
|
467
|
+
const { data, error } = await insforge.payments.razorpay.createSubscription(
|
|
468
|
+
"test",
|
|
469
|
+
{
|
|
470
|
+
planId: "plan_123",
|
|
471
|
+
totalCount: 12,
|
|
472
|
+
subject: { type: "team", id: "team_123" },
|
|
473
|
+
customerName: "Ada Lovelace",
|
|
474
|
+
customerEmail: "ada@example.com",
|
|
475
|
+
},
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
if (!error && data) {
|
|
479
|
+
const checkout = new Razorpay({
|
|
480
|
+
...data.checkoutOptions,
|
|
481
|
+
handler: async (response) => {
|
|
482
|
+
await insforge.payments.razorpay.verifySubscription("test", {
|
|
483
|
+
subscriptionId: response.razorpay_subscription_id,
|
|
484
|
+
paymentId: response.razorpay_payment_id,
|
|
485
|
+
signature: response.razorpay_signature,
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
checkout.open();
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### `razorpay.cancelSubscription()`
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
await insforge.payments.razorpay.cancelSubscription("test", "sub_123", {
|
|
498
|
+
cancelAtCycleEnd: false,
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### `razorpay.pauseSubscription()` / `razorpay.resumeSubscription()`
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
await insforge.payments.razorpay.pauseSubscription("test", "sub_123");
|
|
506
|
+
await insforge.payments.razorpay.resumeSubscription("test", "sub_123");
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Razorpay webhook setup is manual in the Razorpay dashboard. Configure keys and copy the webhook URL, secret, and recommended events from the InsForge payments settings UI.
|
|
510
|
+
|
|
433
511
|
## Database Methods
|
|
434
512
|
|
|
435
513
|
**Note:** Database operations use [@supabase/postgrest-js](https://github.com/supabase/postgrest-js) under the hood, providing full PostgREST compatibility including advanced features like OR conditions, complex joins, and aggregations.
|
|
@@ -692,7 +770,7 @@ Create AI chat completions with support for both streaming and non-streaming res
|
|
|
692
770
|
#### Non-Streaming
|
|
693
771
|
|
|
694
772
|
```javascript
|
|
695
|
-
const
|
|
773
|
+
const completion = await insforge.ai.chat.completions.create({
|
|
696
774
|
model: "anthropic/claude-3.5-haiku",
|
|
697
775
|
messages: [
|
|
698
776
|
{ role: "system", content: "You are a helpful assistant" },
|
|
@@ -701,32 +779,27 @@ const { data, error } = await insforge.ai.chat.completions.create({
|
|
|
701
779
|
temperature: 0.7,
|
|
702
780
|
maxTokens: 500,
|
|
703
781
|
});
|
|
704
|
-
//
|
|
705
|
-
//
|
|
706
|
-
// usage
|
|
707
|
-
// model
|
|
782
|
+
// Returns an OpenAI-like completion object directly (not a { data, error } envelope):
|
|
783
|
+
// completion.choices[0].message.content - the complete AI response text
|
|
784
|
+
// completion.usage - token usage information
|
|
785
|
+
// completion.model - the model used for generation
|
|
786
|
+
console.log(completion.choices[0].message.content);
|
|
708
787
|
```
|
|
709
788
|
|
|
710
789
|
#### Streaming
|
|
711
790
|
|
|
712
791
|
```javascript
|
|
713
|
-
// Returns async iterable for real-time streaming
|
|
792
|
+
// Returns an async iterable of OpenAI-like chunks for real-time streaming
|
|
714
793
|
const stream = await insforge.ai.chat.completions.create({
|
|
715
794
|
model: "anthropic/claude-3.5-haiku",
|
|
716
795
|
messages: [{ role: "user", content: "Tell me a story" }],
|
|
717
796
|
stream: true,
|
|
718
797
|
});
|
|
719
798
|
|
|
720
|
-
//
|
|
721
|
-
for await (const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
process.stdout.write(event.chunk);
|
|
725
|
-
}
|
|
726
|
-
if (event.done) {
|
|
727
|
-
// Stream complete
|
|
728
|
-
console.log("\nStream finished");
|
|
729
|
-
}
|
|
799
|
+
// Each chunk carries an incremental delta in choices[0].delta.content
|
|
800
|
+
for await (const chunk of stream) {
|
|
801
|
+
const delta = chunk.choices[0]?.delta?.content;
|
|
802
|
+
if (delta) process.stdout.write(delta);
|
|
730
803
|
}
|
|
731
804
|
```
|
|
732
805
|
|
|
@@ -734,42 +807,67 @@ for await (const event of stream) {
|
|
|
734
807
|
|
|
735
808
|
- `model` (string, required): AI model to use (e.g., 'anthropic/claude-3.5-haiku', 'openai/gpt-4', etc.)
|
|
736
809
|
- `messages` (array): Conversation messages with role ('system', 'user', 'assistant') and content
|
|
737
|
-
- `
|
|
738
|
-
- `systemPrompt` (string): System prompt for the conversation
|
|
739
|
-
- `temperature` (number): Sampling temperature (0-1)
|
|
810
|
+
- `temperature` (number): Sampling temperature (0-2)
|
|
740
811
|
- `maxTokens` (number): Maximum tokens to generate
|
|
741
|
-
- `topP` (number): Top-p sampling parameter
|
|
812
|
+
- `topP` (number): Top-p sampling parameter (0-1)
|
|
742
813
|
- `stream` (boolean): Enable streaming mode
|
|
814
|
+
- `thinking` (boolean): Enable chain-of-thought reasoning (supported models)
|
|
815
|
+
- `webSearch`, `fileParser`, `tools`, `toolChoice`, `parallelToolCalls`: Optional plugin/tool-calling options — see the SDK source for their shapes
|
|
743
816
|
|
|
744
817
|
### `ai.images.generate()`
|
|
745
818
|
|
|
746
819
|
Generate images using AI models.
|
|
747
820
|
|
|
748
821
|
```javascript
|
|
749
|
-
|
|
750
|
-
|
|
822
|
+
// Text-to-image
|
|
823
|
+
const image = await insforge.ai.images.generate({
|
|
824
|
+
model: "google/gemini-3-pro-image-preview",
|
|
751
825
|
prompt: "A serene landscape with mountains at sunset",
|
|
752
|
-
size: "1024x1024",
|
|
753
|
-
numImages: 1,
|
|
754
|
-
quality: "hd",
|
|
755
|
-
style: "vivid",
|
|
756
826
|
});
|
|
757
|
-
//
|
|
758
|
-
//
|
|
827
|
+
// Returns an OpenAI-like image object directly (not a { data, error } envelope):
|
|
828
|
+
// image.data[i].b64_json - base64-encoded image (no `data:` URI prefix)
|
|
829
|
+
// image.data[i].content - text output, for text-capable image models
|
|
830
|
+
// image.usage - token usage (when reported by the model)
|
|
831
|
+
const base64Png = image.data[0].b64_json;
|
|
832
|
+
|
|
833
|
+
// Image-to-image — pass source images as URLs or base64 data URIs
|
|
834
|
+
const edited = await insforge.ai.images.generate({
|
|
835
|
+
model: "google/gemini-3-pro-image-preview",
|
|
836
|
+
prompt: "Turn this into a watercolor painting",
|
|
837
|
+
images: [{ url: "https://example.com/input.jpg" }],
|
|
838
|
+
});
|
|
759
839
|
```
|
|
760
840
|
|
|
761
841
|
#### Parameters
|
|
762
842
|
|
|
763
|
-
- `model` (string, required): Image generation model (e.g., 'google/gemini-
|
|
843
|
+
- `model` (string, required): Image generation model (e.g., 'google/gemini-3-pro-image-preview', 'openai/dall-e-3')
|
|
764
844
|
- `prompt` (string, required): Text description of the image to generate
|
|
765
|
-
- `
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
845
|
+
- `images` (array): Optional source images for image-to-image, each `{ url: string }` (HTTPS URL or `data:` base64 URI)
|
|
846
|
+
|
|
847
|
+
> The SDK normalizes generated images to base64 and exposes them as `image.data[i].b64_json`.
|
|
848
|
+
|
|
849
|
+
### `ai.embeddings.create()`
|
|
850
|
+
|
|
851
|
+
Create embeddings for one or more text inputs.
|
|
852
|
+
|
|
853
|
+
```javascript
|
|
854
|
+
const embeddings = await insforge.ai.embeddings.create({
|
|
855
|
+
model: "openai/text-embedding-3-small",
|
|
856
|
+
input: "Hello world", // or string[] for batch input
|
|
857
|
+
});
|
|
858
|
+
// Returns an OpenAI-like embeddings object directly (not a { data, error } envelope):
|
|
859
|
+
// embeddings.data[i].embedding - the vector (number[]) for input i
|
|
860
|
+
// embeddings.usage - token usage information
|
|
861
|
+
// embeddings.model - the model used
|
|
862
|
+
console.log(embeddings.data[0].embedding);
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
#### Parameters
|
|
866
|
+
|
|
867
|
+
- `model` (string, required): Embedding model (e.g., 'openai/text-embedding-3-small')
|
|
868
|
+
- `input` (string | string[], required): Text(s) to embed
|
|
869
|
+
- `dimensions` (number): Output dimensions, if supported by the model
|
|
870
|
+
- `encoding_format` ('float' | 'base64'): Encoding of the returned vectors
|
|
773
871
|
|
|
774
872
|
### Complete AI Example
|
|
775
873
|
|
|
@@ -781,11 +879,11 @@ const insforge = createClient({
|
|
|
781
879
|
});
|
|
782
880
|
|
|
783
881
|
// Chat completion
|
|
784
|
-
const
|
|
882
|
+
const chat = await insforge.ai.chat.completions.create({
|
|
785
883
|
model: "anthropic/claude-3.5-haiku",
|
|
786
884
|
messages: [{ role: "user", content: "What is the capital of France?" }],
|
|
787
885
|
});
|
|
788
|
-
console.log(chat.
|
|
886
|
+
console.log(chat.choices[0].message.content); // "The capital of France is Paris."
|
|
789
887
|
|
|
790
888
|
// Streaming chat
|
|
791
889
|
const stream = await insforge.ai.chat.completions.create({
|
|
@@ -795,21 +893,27 @@ const stream = await insforge.ai.chat.completions.create({
|
|
|
795
893
|
});
|
|
796
894
|
|
|
797
895
|
let fullResponse = "";
|
|
798
|
-
for await (const
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
896
|
+
for await (const chunk of stream) {
|
|
897
|
+
const delta = chunk.choices[0]?.delta?.content;
|
|
898
|
+
if (delta) {
|
|
899
|
+
fullResponse += delta;
|
|
900
|
+
process.stdout.write(delta);
|
|
802
901
|
}
|
|
803
902
|
}
|
|
804
903
|
|
|
805
904
|
// Image generation
|
|
806
|
-
const
|
|
807
|
-
model: "google/gemini-
|
|
905
|
+
const image = await insforge.ai.images.generate({
|
|
906
|
+
model: "google/gemini-3-pro-image-preview",
|
|
808
907
|
prompt: "A futuristic city with flying cars",
|
|
809
|
-
size: "1024x1024",
|
|
810
|
-
quality: "hd",
|
|
811
908
|
});
|
|
812
|
-
|
|
909
|
+
const base64Png = image.data[0].b64_json; // base64-encoded image
|
|
910
|
+
|
|
911
|
+
// Embeddings
|
|
912
|
+
const embeddings = await insforge.ai.embeddings.create({
|
|
913
|
+
model: "openai/text-embedding-3-small",
|
|
914
|
+
input: "Vectorize this sentence",
|
|
915
|
+
});
|
|
916
|
+
console.log(embeddings.data[0].embedding); // number[]
|
|
813
917
|
```
|
|
814
918
|
|
|
815
919
|
## Types (from @insforge/shared-schemas)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse } from '@insforge/shared-schemas';
|
|
1
|
+
import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse, RazorpayEnvironment, CreateRazorpayOrderBody, CreateRazorpayOrderResponse, VerifyRazorpayOrderBody, VerifyRazorpayOrderResponse, CreateRazorpaySubscriptionBody, CreateRazorpaySubscriptionResponse, VerifyRazorpaySubscriptionBody, VerifyRazorpaySubscriptionResponse, cancelRazorpaySubscriptionBodySchema, CancelRazorpaySubscriptionResponse, PauseRazorpaySubscriptionResponse, ResumeRazorpaySubscriptionResponse } from '@insforge/shared-schemas';
|
|
2
2
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -758,7 +758,7 @@ declare class Images {
|
|
|
758
758
|
* model: 'dall-e-3',
|
|
759
759
|
* prompt: 'A sunset over mountains',
|
|
760
760
|
* });
|
|
761
|
-
* console.log(response.
|
|
761
|
+
* console.log(response.data[0].b64_json);
|
|
762
762
|
*
|
|
763
763
|
* // Image-to-image (with input images)
|
|
764
764
|
* const response = await client.ai.images.generate({
|
|
@@ -1013,14 +1013,15 @@ interface PaymentsResponse<T> {
|
|
|
1013
1013
|
data: T | null;
|
|
1014
1014
|
error: InsForgeError | null;
|
|
1015
1015
|
}
|
|
1016
|
+
type CancelRazorpaySubscriptionBodyInput = (typeof cancelRazorpaySubscriptionBodySchema)["_input"];
|
|
1016
1017
|
/**
|
|
1017
|
-
*
|
|
1018
|
+
* Stripe runtime payment flows.
|
|
1018
1019
|
*
|
|
1019
1020
|
* These methods are safe to call from generated app frontends with the current
|
|
1020
1021
|
* user token or anon key. Admin-only Stripe key/catalog APIs are intentionally
|
|
1021
1022
|
* not exposed here.
|
|
1022
1023
|
*/
|
|
1023
|
-
declare class
|
|
1024
|
+
declare class StripePayments {
|
|
1024
1025
|
private http;
|
|
1025
1026
|
constructor(http: HttpClient);
|
|
1026
1027
|
/**
|
|
@@ -1028,9 +1029,9 @@ declare class Payments {
|
|
|
1028
1029
|
*
|
|
1029
1030
|
* @example
|
|
1030
1031
|
* ```typescript
|
|
1031
|
-
* const { data, error } = await client.payments.createCheckoutSession('test', {
|
|
1032
|
+
* const { data, error } = await client.payments.stripe.createCheckoutSession('test', {
|
|
1032
1033
|
* mode: 'payment',
|
|
1033
|
-
* lineItems: [{
|
|
1034
|
+
* lineItems: [{ priceId: 'price_123', quantity: 1 }],
|
|
1034
1035
|
* successUrl: `${window.location.origin}/success`,
|
|
1035
1036
|
* cancelUrl: `${window.location.origin}/pricing`
|
|
1036
1037
|
* });
|
|
@@ -1046,6 +1047,32 @@ declare class Payments {
|
|
|
1046
1047
|
*/
|
|
1047
1048
|
createCustomerPortalSession(environment: StripeEnvironment, request: CreateCustomerPortalSessionBody): Promise<PaymentsResponse<CreateCustomerPortalSessionResponse>>;
|
|
1048
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Razorpay runtime payment flows.
|
|
1052
|
+
*
|
|
1053
|
+
* Razorpay Checkout is client-rendered: create an order or subscription here,
|
|
1054
|
+
* pass the returned checkoutOptions to Razorpay Checkout.js, then verify the
|
|
1055
|
+
* signed payment response with the matching verify method.
|
|
1056
|
+
*/
|
|
1057
|
+
declare class RazorpayPayments {
|
|
1058
|
+
private http;
|
|
1059
|
+
constructor(http: HttpClient);
|
|
1060
|
+
createOrder(environment: RazorpayEnvironment, request: CreateRazorpayOrderBody): Promise<PaymentsResponse<CreateRazorpayOrderResponse>>;
|
|
1061
|
+
verifyOrder(environment: RazorpayEnvironment, request: VerifyRazorpayOrderBody): Promise<PaymentsResponse<VerifyRazorpayOrderResponse>>;
|
|
1062
|
+
createSubscription(environment: RazorpayEnvironment, request: CreateRazorpaySubscriptionBody): Promise<PaymentsResponse<CreateRazorpaySubscriptionResponse>>;
|
|
1063
|
+
verifySubscription(environment: RazorpayEnvironment, request: VerifyRazorpaySubscriptionBody): Promise<PaymentsResponse<VerifyRazorpaySubscriptionResponse>>;
|
|
1064
|
+
cancelSubscription(environment: RazorpayEnvironment, subscriptionId: string, request?: CancelRazorpaySubscriptionBodyInput): Promise<PaymentsResponse<CancelRazorpaySubscriptionResponse>>;
|
|
1065
|
+
pauseSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<PauseRazorpaySubscriptionResponse>>;
|
|
1066
|
+
resumeSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<ResumeRazorpaySubscriptionResponse>>;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Provider-scoped payments client.
|
|
1070
|
+
*/
|
|
1071
|
+
declare class Payments {
|
|
1072
|
+
readonly stripe: StripePayments;
|
|
1073
|
+
readonly razorpay: RazorpayPayments;
|
|
1074
|
+
constructor(http: HttpClient);
|
|
1075
|
+
}
|
|
1049
1076
|
|
|
1050
1077
|
/**
|
|
1051
1078
|
* Main InsForge SDK Client
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse } from '@insforge/shared-schemas';
|
|
1
|
+
import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse, RazorpayEnvironment, CreateRazorpayOrderBody, CreateRazorpayOrderResponse, VerifyRazorpayOrderBody, VerifyRazorpayOrderResponse, CreateRazorpaySubscriptionBody, CreateRazorpaySubscriptionResponse, VerifyRazorpaySubscriptionBody, VerifyRazorpaySubscriptionResponse, cancelRazorpaySubscriptionBodySchema, CancelRazorpaySubscriptionResponse, PauseRazorpaySubscriptionResponse, ResumeRazorpaySubscriptionResponse } from '@insforge/shared-schemas';
|
|
2
2
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -758,7 +758,7 @@ declare class Images {
|
|
|
758
758
|
* model: 'dall-e-3',
|
|
759
759
|
* prompt: 'A sunset over mountains',
|
|
760
760
|
* });
|
|
761
|
-
* console.log(response.
|
|
761
|
+
* console.log(response.data[0].b64_json);
|
|
762
762
|
*
|
|
763
763
|
* // Image-to-image (with input images)
|
|
764
764
|
* const response = await client.ai.images.generate({
|
|
@@ -1013,14 +1013,15 @@ interface PaymentsResponse<T> {
|
|
|
1013
1013
|
data: T | null;
|
|
1014
1014
|
error: InsForgeError | null;
|
|
1015
1015
|
}
|
|
1016
|
+
type CancelRazorpaySubscriptionBodyInput = (typeof cancelRazorpaySubscriptionBodySchema)["_input"];
|
|
1016
1017
|
/**
|
|
1017
|
-
*
|
|
1018
|
+
* Stripe runtime payment flows.
|
|
1018
1019
|
*
|
|
1019
1020
|
* These methods are safe to call from generated app frontends with the current
|
|
1020
1021
|
* user token or anon key. Admin-only Stripe key/catalog APIs are intentionally
|
|
1021
1022
|
* not exposed here.
|
|
1022
1023
|
*/
|
|
1023
|
-
declare class
|
|
1024
|
+
declare class StripePayments {
|
|
1024
1025
|
private http;
|
|
1025
1026
|
constructor(http: HttpClient);
|
|
1026
1027
|
/**
|
|
@@ -1028,9 +1029,9 @@ declare class Payments {
|
|
|
1028
1029
|
*
|
|
1029
1030
|
* @example
|
|
1030
1031
|
* ```typescript
|
|
1031
|
-
* const { data, error } = await client.payments.createCheckoutSession('test', {
|
|
1032
|
+
* const { data, error } = await client.payments.stripe.createCheckoutSession('test', {
|
|
1032
1033
|
* mode: 'payment',
|
|
1033
|
-
* lineItems: [{
|
|
1034
|
+
* lineItems: [{ priceId: 'price_123', quantity: 1 }],
|
|
1034
1035
|
* successUrl: `${window.location.origin}/success`,
|
|
1035
1036
|
* cancelUrl: `${window.location.origin}/pricing`
|
|
1036
1037
|
* });
|
|
@@ -1046,6 +1047,32 @@ declare class Payments {
|
|
|
1046
1047
|
*/
|
|
1047
1048
|
createCustomerPortalSession(environment: StripeEnvironment, request: CreateCustomerPortalSessionBody): Promise<PaymentsResponse<CreateCustomerPortalSessionResponse>>;
|
|
1048
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Razorpay runtime payment flows.
|
|
1052
|
+
*
|
|
1053
|
+
* Razorpay Checkout is client-rendered: create an order or subscription here,
|
|
1054
|
+
* pass the returned checkoutOptions to Razorpay Checkout.js, then verify the
|
|
1055
|
+
* signed payment response with the matching verify method.
|
|
1056
|
+
*/
|
|
1057
|
+
declare class RazorpayPayments {
|
|
1058
|
+
private http;
|
|
1059
|
+
constructor(http: HttpClient);
|
|
1060
|
+
createOrder(environment: RazorpayEnvironment, request: CreateRazorpayOrderBody): Promise<PaymentsResponse<CreateRazorpayOrderResponse>>;
|
|
1061
|
+
verifyOrder(environment: RazorpayEnvironment, request: VerifyRazorpayOrderBody): Promise<PaymentsResponse<VerifyRazorpayOrderResponse>>;
|
|
1062
|
+
createSubscription(environment: RazorpayEnvironment, request: CreateRazorpaySubscriptionBody): Promise<PaymentsResponse<CreateRazorpaySubscriptionResponse>>;
|
|
1063
|
+
verifySubscription(environment: RazorpayEnvironment, request: VerifyRazorpaySubscriptionBody): Promise<PaymentsResponse<VerifyRazorpaySubscriptionResponse>>;
|
|
1064
|
+
cancelSubscription(environment: RazorpayEnvironment, subscriptionId: string, request?: CancelRazorpaySubscriptionBodyInput): Promise<PaymentsResponse<CancelRazorpaySubscriptionResponse>>;
|
|
1065
|
+
pauseSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<PauseRazorpaySubscriptionResponse>>;
|
|
1066
|
+
resumeSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<ResumeRazorpaySubscriptionResponse>>;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Provider-scoped payments client.
|
|
1070
|
+
*/
|
|
1071
|
+
declare class Payments {
|
|
1072
|
+
readonly stripe: StripePayments;
|
|
1073
|
+
readonly razorpay: RazorpayPayments;
|
|
1074
|
+
constructor(http: HttpClient);
|
|
1075
|
+
}
|
|
1049
1076
|
|
|
1050
1077
|
/**
|
|
1051
1078
|
* Main InsForge SDK Client
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-
|
|
2
|
-
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-
|
|
1
|
+
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-Co8KxT-n.mjs';
|
|
2
|
+
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-Co8KxT-n.mjs';
|
|
3
3
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
|
|
4
4
|
import '@supabase/postgrest-js';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-
|
|
2
|
-
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-
|
|
1
|
+
import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-Co8KxT-n.js';
|
|
2
|
+
export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-Co8KxT-n.js';
|
|
3
3
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
|
|
4
4
|
import '@supabase/postgrest-js';
|
|
5
5
|
|