@blinkdotnew/sdk 0.6.2 → 0.7.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 +42 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +71 -0
- package/dist/index.mjs +71 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,13 @@ const screenshotUrl = await blink.data.screenshot("https://competitor.com")
|
|
|
56
56
|
const searchResults = await blink.data.search("chatgpt latest news", { type: 'news' })
|
|
57
57
|
const localResults = await blink.data.search("best restaurants", { location: "San Francisco,CA,United States" })
|
|
58
58
|
|
|
59
|
+
// Notifications (NEW!)
|
|
60
|
+
const { success } = await blink.notifications.email({
|
|
61
|
+
to: 'customer@example.com',
|
|
62
|
+
subject: 'Your order has shipped!',
|
|
63
|
+
html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
|
|
64
|
+
})
|
|
65
|
+
|
|
59
66
|
// Secure API proxy (call external APIs with secret substitution)
|
|
60
67
|
const response = await blink.data.fetch({
|
|
61
68
|
url: "https://api.sendgrid.com/v3/mail/send",
|
|
@@ -635,7 +642,7 @@ try {
|
|
|
635
642
|
### Error Handling
|
|
636
643
|
|
|
637
644
|
```typescript
|
|
638
|
-
import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError, BlinkRealtimeError } from '@blinkdotnew/sdk'
|
|
645
|
+
import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError, BlinkRealtimeError, BlinkNotificationsError } from '@blinkdotnew/sdk'
|
|
639
646
|
|
|
640
647
|
try {
|
|
641
648
|
const user = await blink.auth.me()
|
|
@@ -745,7 +752,7 @@ All `{{secret_name}}` placeholders are replaced with encrypted values from your
|
|
|
745
752
|
|
|
746
753
|
### React
|
|
747
754
|
|
|
748
|
-
```
|
|
755
|
+
```typitten
|
|
749
756
|
import { createClient } from '@blinkdotnew/sdk'
|
|
750
757
|
import { useState, useEffect } from 'react'
|
|
751
758
|
|
|
@@ -1038,4 +1045,36 @@ MIT © Blink Team
|
|
|
1038
1045
|
|
|
1039
1046
|
**Made with ❤️ by the Blink team**
|
|
1040
1047
|
|
|
1041
|
-
🤖 **Ready to build your next app?** Visit [blink.new](https://blink.new) and let our AI create it for you in seconds!
|
|
1048
|
+
🤖 **Ready to build your next app?** Visit [blink.new](https://blink.new) and let our AI create it for you in seconds!
|
|
1049
|
+
|
|
1050
|
+
### Notifications (NEW!)
|
|
1051
|
+
|
|
1052
|
+
```typescript
|
|
1053
|
+
// Send a simple email
|
|
1054
|
+
const { success, messageId } = await blink.notifications.email({
|
|
1055
|
+
to: 'customer@example.com',
|
|
1056
|
+
subject: 'Your order has shipped!',
|
|
1057
|
+
html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
// Send an email with attachments, a custom 'from' name, and a 'replyTo' address
|
|
1061
|
+
const { success } = await blink.notifications.email({
|
|
1062
|
+
to: ['team@example.com', 'manager@example.com'],
|
|
1063
|
+
from: 'Blink Invoicing', // Displays as: "Blink Invoicing" <noreply@project.blink-email.com>
|
|
1064
|
+
replyTo: 'support@example.com',
|
|
1065
|
+
subject: 'New Invoice',
|
|
1066
|
+
html: '<p>Please find the invoice attached.</p>',
|
|
1067
|
+
attachments: [
|
|
1068
|
+
{ url: 'https://example.com/invoice.pdf', filename: 'invoice.pdf' }
|
|
1069
|
+
]
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
// Handle errors
|
|
1073
|
+
try {
|
|
1074
|
+
await blink.notifications.email({ to: 'invalid-email' });
|
|
1075
|
+
} catch (error) {
|
|
1076
|
+
if (error instanceof BlinkNotificationsError) {
|
|
1077
|
+
console.error('Failed to send email:', error.message);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, BlinkNotifications, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
|
|
2
2
|
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkRealtime, BlinkRealtimeError, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, PresenceUser, QueryOptions, RealtimeChannel, RealtimeGetMessagesOptions, RealtimeMessage, RealtimePublishOptions, RealtimeSubscribeOptions, SearchRequest, SearchResponse, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -260,6 +260,7 @@ interface BlinkClient {
|
|
|
260
260
|
ai: BlinkAI;
|
|
261
261
|
data: BlinkData;
|
|
262
262
|
realtime: BlinkRealtime;
|
|
263
|
+
notifications: BlinkNotifications;
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
265
266
|
* Create a new Blink client instance
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, BlinkNotifications, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
|
|
2
2
|
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkRealtime, BlinkRealtimeError, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, PresenceUser, QueryOptions, RealtimeChannel, RealtimeGetMessagesOptions, RealtimeMessage, RealtimePublishOptions, RealtimeSubscribeOptions, SearchRequest, SearchResponse, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -260,6 +260,7 @@ interface BlinkClient {
|
|
|
260
260
|
ai: BlinkAI;
|
|
261
261
|
data: BlinkData;
|
|
262
262
|
realtime: BlinkRealtime;
|
|
263
|
+
notifications: BlinkNotifications;
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
265
266
|
* Create a new Blink client instance
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,8 @@ var BlinkRealtimeError = class extends BlinkError {
|
|
|
59
59
|
this.name = "BlinkRealtimeError";
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
var BlinkNotificationsError = class extends BlinkError {
|
|
63
|
+
};
|
|
62
64
|
|
|
63
65
|
// ../core/src/query-builder.ts
|
|
64
66
|
function buildFilterQuery(condition) {
|
|
@@ -2807,6 +2809,73 @@ var BlinkRealtimeImpl = class {
|
|
|
2807
2809
|
}
|
|
2808
2810
|
};
|
|
2809
2811
|
|
|
2812
|
+
// src/notifications.ts
|
|
2813
|
+
var BlinkNotificationsImpl = class {
|
|
2814
|
+
constructor(httpClient) {
|
|
2815
|
+
this.httpClient = httpClient;
|
|
2816
|
+
}
|
|
2817
|
+
/**
|
|
2818
|
+
* Sends an email using the Blink Notifications API.
|
|
2819
|
+
*
|
|
2820
|
+
* @param params - An object containing the details for the email.
|
|
2821
|
+
* - `to`: The recipient's email address or an array of addresses.
|
|
2822
|
+
* - `subject`: The subject line of the email.
|
|
2823
|
+
* - `html`: The HTML body of the email. For best results across all email
|
|
2824
|
+
* clients (like Gmail, Outlook), use inline CSS and table-based layouts.
|
|
2825
|
+
* - `text`: A plain-text version of the email body (optional).
|
|
2826
|
+
* - `from`: A custom sender name (e.g., "Acme Inc"). The email address will
|
|
2827
|
+
* be auto-generated by the project (e.g., "noreply@project.blink-email.com").
|
|
2828
|
+
* - `replyTo`: An email address for recipients to reply to (optional).
|
|
2829
|
+
* - `cc`: A CC recipient's email address or an array of addresses (optional).
|
|
2830
|
+
* - `bcc`: A BCC recipient's email address or an array of addresses (optional).
|
|
2831
|
+
* - `attachments`: An array of objects for files to attach, each with a `url`.
|
|
2832
|
+
* The file at the URL will be fetched and attached by the server.
|
|
2833
|
+
*
|
|
2834
|
+
* @example
|
|
2835
|
+
* ```ts
|
|
2836
|
+
* // Send a simple email
|
|
2837
|
+
* const { success, messageId } = await blink.notifications.email({
|
|
2838
|
+
* to: 'customer@example.com',
|
|
2839
|
+
* subject: 'Your order has shipped!',
|
|
2840
|
+
* html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
|
|
2841
|
+
* });
|
|
2842
|
+
*
|
|
2843
|
+
* // Send an email with attachments and a custom from name
|
|
2844
|
+
* const { success } = await blink.notifications.email({
|
|
2845
|
+
* to: ['team@example.com', 'manager@example.com'],
|
|
2846
|
+
* subject: 'New Invoice',
|
|
2847
|
+
* from: 'Blink Invoicing',
|
|
2848
|
+
* html: '<p>Please find the invoice attached.</p>',
|
|
2849
|
+
* attachments: [
|
|
2850
|
+
* { url: 'https://example.com/invoice.pdf', filename: 'invoice.pdf' }
|
|
2851
|
+
* ]
|
|
2852
|
+
* });
|
|
2853
|
+
* ```
|
|
2854
|
+
*
|
|
2855
|
+
* @returns A promise that resolves with an object containing the status of the email send.
|
|
2856
|
+
* - `success`: A boolean indicating if the email was sent successfully.
|
|
2857
|
+
* - `messageId`: The unique ID of the message from the email provider.
|
|
2858
|
+
*/
|
|
2859
|
+
async email(params) {
|
|
2860
|
+
try {
|
|
2861
|
+
if (!params.to || !params.subject || !params.html && !params.text) {
|
|
2862
|
+
throw new BlinkNotificationsError('The "to", "subject", and either "html" or "text" fields are required.');
|
|
2863
|
+
}
|
|
2864
|
+
const response = await this.httpClient.post("/notifications/email", params);
|
|
2865
|
+
if (!response.data || typeof response.data.success !== "boolean") {
|
|
2866
|
+
throw new BlinkNotificationsError("Invalid response from email API");
|
|
2867
|
+
}
|
|
2868
|
+
return response.data;
|
|
2869
|
+
} catch (error) {
|
|
2870
|
+
if (error instanceof BlinkNotificationsError) {
|
|
2871
|
+
throw error;
|
|
2872
|
+
}
|
|
2873
|
+
const errorMessage = error.response?.data?.error?.message || error.message || "An unknown error occurred";
|
|
2874
|
+
throw new BlinkNotificationsError(`Failed to send email: ${errorMessage}`, error.response?.data?.error);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
|
|
2810
2879
|
// src/client.ts
|
|
2811
2880
|
var BlinkClientImpl = class {
|
|
2812
2881
|
auth;
|
|
@@ -2815,6 +2884,7 @@ var BlinkClientImpl = class {
|
|
|
2815
2884
|
ai;
|
|
2816
2885
|
data;
|
|
2817
2886
|
realtime;
|
|
2887
|
+
notifications;
|
|
2818
2888
|
httpClient;
|
|
2819
2889
|
constructor(config) {
|
|
2820
2890
|
this.auth = new BlinkAuth(config);
|
|
@@ -2828,6 +2898,7 @@ var BlinkClientImpl = class {
|
|
|
2828
2898
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2829
2899
|
this.data = new BlinkDataImpl(this.httpClient, config.projectId);
|
|
2830
2900
|
this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
|
|
2901
|
+
this.notifications = new BlinkNotificationsImpl(this.httpClient);
|
|
2831
2902
|
}
|
|
2832
2903
|
};
|
|
2833
2904
|
function createClient(config) {
|
package/dist/index.mjs
CHANGED
|
@@ -57,6 +57,8 @@ var BlinkRealtimeError = class extends BlinkError {
|
|
|
57
57
|
this.name = "BlinkRealtimeError";
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
var BlinkNotificationsError = class extends BlinkError {
|
|
61
|
+
};
|
|
60
62
|
|
|
61
63
|
// ../core/src/query-builder.ts
|
|
62
64
|
function buildFilterQuery(condition) {
|
|
@@ -2805,6 +2807,73 @@ var BlinkRealtimeImpl = class {
|
|
|
2805
2807
|
}
|
|
2806
2808
|
};
|
|
2807
2809
|
|
|
2810
|
+
// src/notifications.ts
|
|
2811
|
+
var BlinkNotificationsImpl = class {
|
|
2812
|
+
constructor(httpClient) {
|
|
2813
|
+
this.httpClient = httpClient;
|
|
2814
|
+
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Sends an email using the Blink Notifications API.
|
|
2817
|
+
*
|
|
2818
|
+
* @param params - An object containing the details for the email.
|
|
2819
|
+
* - `to`: The recipient's email address or an array of addresses.
|
|
2820
|
+
* - `subject`: The subject line of the email.
|
|
2821
|
+
* - `html`: The HTML body of the email. For best results across all email
|
|
2822
|
+
* clients (like Gmail, Outlook), use inline CSS and table-based layouts.
|
|
2823
|
+
* - `text`: A plain-text version of the email body (optional).
|
|
2824
|
+
* - `from`: A custom sender name (e.g., "Acme Inc"). The email address will
|
|
2825
|
+
* be auto-generated by the project (e.g., "noreply@project.blink-email.com").
|
|
2826
|
+
* - `replyTo`: An email address for recipients to reply to (optional).
|
|
2827
|
+
* - `cc`: A CC recipient's email address or an array of addresses (optional).
|
|
2828
|
+
* - `bcc`: A BCC recipient's email address or an array of addresses (optional).
|
|
2829
|
+
* - `attachments`: An array of objects for files to attach, each with a `url`.
|
|
2830
|
+
* The file at the URL will be fetched and attached by the server.
|
|
2831
|
+
*
|
|
2832
|
+
* @example
|
|
2833
|
+
* ```ts
|
|
2834
|
+
* // Send a simple email
|
|
2835
|
+
* const { success, messageId } = await blink.notifications.email({
|
|
2836
|
+
* to: 'customer@example.com',
|
|
2837
|
+
* subject: 'Your order has shipped!',
|
|
2838
|
+
* html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
|
|
2839
|
+
* });
|
|
2840
|
+
*
|
|
2841
|
+
* // Send an email with attachments and a custom from name
|
|
2842
|
+
* const { success } = await blink.notifications.email({
|
|
2843
|
+
* to: ['team@example.com', 'manager@example.com'],
|
|
2844
|
+
* subject: 'New Invoice',
|
|
2845
|
+
* from: 'Blink Invoicing',
|
|
2846
|
+
* html: '<p>Please find the invoice attached.</p>',
|
|
2847
|
+
* attachments: [
|
|
2848
|
+
* { url: 'https://example.com/invoice.pdf', filename: 'invoice.pdf' }
|
|
2849
|
+
* ]
|
|
2850
|
+
* });
|
|
2851
|
+
* ```
|
|
2852
|
+
*
|
|
2853
|
+
* @returns A promise that resolves with an object containing the status of the email send.
|
|
2854
|
+
* - `success`: A boolean indicating if the email was sent successfully.
|
|
2855
|
+
* - `messageId`: The unique ID of the message from the email provider.
|
|
2856
|
+
*/
|
|
2857
|
+
async email(params) {
|
|
2858
|
+
try {
|
|
2859
|
+
if (!params.to || !params.subject || !params.html && !params.text) {
|
|
2860
|
+
throw new BlinkNotificationsError('The "to", "subject", and either "html" or "text" fields are required.');
|
|
2861
|
+
}
|
|
2862
|
+
const response = await this.httpClient.post("/notifications/email", params);
|
|
2863
|
+
if (!response.data || typeof response.data.success !== "boolean") {
|
|
2864
|
+
throw new BlinkNotificationsError("Invalid response from email API");
|
|
2865
|
+
}
|
|
2866
|
+
return response.data;
|
|
2867
|
+
} catch (error) {
|
|
2868
|
+
if (error instanceof BlinkNotificationsError) {
|
|
2869
|
+
throw error;
|
|
2870
|
+
}
|
|
2871
|
+
const errorMessage = error.response?.data?.error?.message || error.message || "An unknown error occurred";
|
|
2872
|
+
throw new BlinkNotificationsError(`Failed to send email: ${errorMessage}`, error.response?.data?.error);
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2808
2877
|
// src/client.ts
|
|
2809
2878
|
var BlinkClientImpl = class {
|
|
2810
2879
|
auth;
|
|
@@ -2813,6 +2882,7 @@ var BlinkClientImpl = class {
|
|
|
2813
2882
|
ai;
|
|
2814
2883
|
data;
|
|
2815
2884
|
realtime;
|
|
2885
|
+
notifications;
|
|
2816
2886
|
httpClient;
|
|
2817
2887
|
constructor(config) {
|
|
2818
2888
|
this.auth = new BlinkAuth(config);
|
|
@@ -2826,6 +2896,7 @@ var BlinkClientImpl = class {
|
|
|
2826
2896
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2827
2897
|
this.data = new BlinkDataImpl(this.httpClient, config.projectId);
|
|
2828
2898
|
this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
|
|
2899
|
+
this.notifications = new BlinkNotificationsImpl(this.httpClient);
|
|
2829
2900
|
}
|
|
2830
2901
|
};
|
|
2831
2902
|
function createClient(config) {
|