@blinkdotnew/sdk 0.6.2 → 0.7.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 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",
@@ -100,6 +107,7 @@ This SDK powers every Blink-generated app with:
100
107
  - **🤖 AI**: Text generation with web search, object generation, image creation, speech synthesis, and transcription
101
108
  - **📄 Data**: Extract text content from documents, secure API proxy with secret substitution, web scraping, screenshots, and web search
102
109
  - **📁 Storage**: File upload, download, and management
110
+ - **📧 Notifications**: Email sending with attachments, custom branding, and delivery tracking
103
111
  - **⚡ Realtime**: WebSocket-based pub/sub messaging, presence tracking, and live updates
104
112
  - **🌐 Universal**: Works on client-side and server-side
105
113
  - **📱 Framework Agnostic**: React, Vue, Svelte, vanilla JS, Node.js, Deno
@@ -492,6 +500,56 @@ const { publicUrl } = await blink.storage.upload(
492
500
  await blink.storage.remove('file1.jpg', 'file2.jpg')
493
501
  ```
494
502
 
503
+ ### Notifications Operations
504
+
505
+ ```typescript
506
+ // Send a simple email
507
+ const { success, messageId } = await blink.notifications.email({
508
+ to: 'customer@example.com',
509
+ subject: 'Your order has shipped!',
510
+ html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
511
+ })
512
+
513
+ // Send an email with attachments and custom sender
514
+ const { success } = await blink.notifications.email({
515
+ to: ['team@example.com', 'manager@example.com'],
516
+ from: 'Blink Invoicing', // Custom sender name
517
+ replyTo: 'support@example.com',
518
+ subject: 'New Invoice',
519
+ html: '<p>Please find the invoice attached.</p>',
520
+ text: 'Please find the invoice attached.', // Plain text fallback
521
+ cc: 'manager@example.com',
522
+ bcc: 'archive@example.com',
523
+ attachments: [
524
+ {
525
+ url: 'https://example.com/invoice.pdf',
526
+ filename: 'invoice.pdf',
527
+ type: 'application/pdf'
528
+ }
529
+ ]
530
+ })
531
+
532
+ // Send to multiple recipients
533
+ const { success } = await blink.notifications.email({
534
+ to: ['user1@example.com', 'user2@example.com'],
535
+ subject: 'Team Update',
536
+ html: '<h2>Weekly Update</h2><p>Here are this week\'s highlights...</p>'
537
+ })
538
+
539
+ // Error handling
540
+ try {
541
+ await blink.notifications.email({
542
+ to: 'customer@example.com',
543
+ subject: 'Welcome!',
544
+ html: '<p>Welcome to our service!</p>'
545
+ })
546
+ } catch (error) {
547
+ if (error instanceof BlinkNotificationsError) {
548
+ console.error('Failed to send email:', error.message)
549
+ }
550
+ }
551
+ ```
552
+
495
553
  ### Realtime Operations
496
554
 
497
555
  ```typescript
@@ -635,7 +693,7 @@ try {
635
693
  ### Error Handling
636
694
 
637
695
  ```typescript
638
- import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError, BlinkRealtimeError } from '@blinkdotnew/sdk'
696
+ import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError, BlinkRealtimeError, BlinkNotificationsError } from '@blinkdotnew/sdk'
639
697
 
640
698
  try {
641
699
  const user = await blink.auth.me()
@@ -745,7 +803,7 @@ All `{{secret_name}}` placeholders are replaced with encrypted values from your
745
803
 
746
804
  ### React
747
805
 
748
- ```typescript
806
+ ```typitten
749
807
  import { createClient } from '@blinkdotnew/sdk'
750
808
  import { useState, useEffect } from 'react'
751
809
 
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,12 @@ var BlinkRealtimeError = class extends BlinkError {
59
59
  this.name = "BlinkRealtimeError";
60
60
  }
61
61
  };
62
+ var BlinkNotificationsError = class extends BlinkError {
63
+ constructor(message, status, details) {
64
+ super(message, "NOTIFICATIONS_ERROR", status, details);
65
+ this.name = "BlinkNotificationsError";
66
+ }
67
+ };
62
68
 
63
69
  // ../core/src/query-builder.ts
64
70
  function buildFilterQuery(condition) {
@@ -2807,6 +2813,73 @@ var BlinkRealtimeImpl = class {
2807
2813
  }
2808
2814
  };
2809
2815
 
2816
+ // src/notifications.ts
2817
+ var BlinkNotificationsImpl = class {
2818
+ constructor(httpClient) {
2819
+ this.httpClient = httpClient;
2820
+ }
2821
+ /**
2822
+ * Sends an email using the Blink Notifications API.
2823
+ *
2824
+ * @param params - An object containing the details for the email.
2825
+ * - `to`: The recipient's email address or an array of addresses.
2826
+ * - `subject`: The subject line of the email.
2827
+ * - `html`: The HTML body of the email. For best results across all email
2828
+ * clients (like Gmail, Outlook), use inline CSS and table-based layouts.
2829
+ * - `text`: A plain-text version of the email body (optional).
2830
+ * - `from`: A custom sender name (e.g., "Acme Inc"). The email address will
2831
+ * be auto-generated by the project (e.g., "noreply@project.blink-email.com").
2832
+ * - `replyTo`: An email address for recipients to reply to (optional).
2833
+ * - `cc`: A CC recipient's email address or an array of addresses (optional).
2834
+ * - `bcc`: A BCC recipient's email address or an array of addresses (optional).
2835
+ * - `attachments`: An array of objects for files to attach, each with a `url`.
2836
+ * The file at the URL will be fetched and attached by the server.
2837
+ *
2838
+ * @example
2839
+ * ```ts
2840
+ * // Send a simple email
2841
+ * const { success, messageId } = await blink.notifications.email({
2842
+ * to: 'customer@example.com',
2843
+ * subject: 'Your order has shipped!',
2844
+ * html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
2845
+ * });
2846
+ *
2847
+ * // Send an email with attachments and a custom from name
2848
+ * const { success } = await blink.notifications.email({
2849
+ * to: ['team@example.com', 'manager@example.com'],
2850
+ * subject: 'New Invoice',
2851
+ * from: 'Blink Invoicing',
2852
+ * html: '<p>Please find the invoice attached.</p>',
2853
+ * attachments: [
2854
+ * { url: 'https://example.com/invoice.pdf', filename: 'invoice.pdf' }
2855
+ * ]
2856
+ * });
2857
+ * ```
2858
+ *
2859
+ * @returns A promise that resolves with an object containing the status of the email send.
2860
+ * - `success`: A boolean indicating if the email was sent successfully.
2861
+ * - `messageId`: The unique ID of the message from the email provider.
2862
+ */
2863
+ async email(params) {
2864
+ try {
2865
+ if (!params.to || !params.subject || !params.html && !params.text) {
2866
+ throw new BlinkNotificationsError('The "to", "subject", and either "html" or "text" fields are required.');
2867
+ }
2868
+ const response = await this.httpClient.post("/notifications/email", params);
2869
+ if (!response.data || typeof response.data.success !== "boolean") {
2870
+ throw new BlinkNotificationsError("Invalid response from email API");
2871
+ }
2872
+ return response.data;
2873
+ } catch (error) {
2874
+ if (error instanceof BlinkNotificationsError) {
2875
+ throw error;
2876
+ }
2877
+ const errorMessage = error.response?.data?.error?.message || error.message || "An unknown error occurred";
2878
+ throw new BlinkNotificationsError(`Failed to send email: ${errorMessage}`, error.response?.status, error.response?.data?.error);
2879
+ }
2880
+ }
2881
+ };
2882
+
2810
2883
  // src/client.ts
2811
2884
  var BlinkClientImpl = class {
2812
2885
  auth;
@@ -2815,6 +2888,7 @@ var BlinkClientImpl = class {
2815
2888
  ai;
2816
2889
  data;
2817
2890
  realtime;
2891
+ notifications;
2818
2892
  httpClient;
2819
2893
  constructor(config) {
2820
2894
  this.auth = new BlinkAuth(config);
@@ -2828,6 +2902,7 @@ var BlinkClientImpl = class {
2828
2902
  this.ai = new BlinkAIImpl(this.httpClient);
2829
2903
  this.data = new BlinkDataImpl(this.httpClient, config.projectId);
2830
2904
  this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
2905
+ this.notifications = new BlinkNotificationsImpl(this.httpClient);
2831
2906
  }
2832
2907
  };
2833
2908
  function createClient(config) {
package/dist/index.mjs CHANGED
@@ -57,6 +57,12 @@ var BlinkRealtimeError = class extends BlinkError {
57
57
  this.name = "BlinkRealtimeError";
58
58
  }
59
59
  };
60
+ var BlinkNotificationsError = class extends BlinkError {
61
+ constructor(message, status, details) {
62
+ super(message, "NOTIFICATIONS_ERROR", status, details);
63
+ this.name = "BlinkNotificationsError";
64
+ }
65
+ };
60
66
 
61
67
  // ../core/src/query-builder.ts
62
68
  function buildFilterQuery(condition) {
@@ -2805,6 +2811,73 @@ var BlinkRealtimeImpl = class {
2805
2811
  }
2806
2812
  };
2807
2813
 
2814
+ // src/notifications.ts
2815
+ var BlinkNotificationsImpl = class {
2816
+ constructor(httpClient) {
2817
+ this.httpClient = httpClient;
2818
+ }
2819
+ /**
2820
+ * Sends an email using the Blink Notifications API.
2821
+ *
2822
+ * @param params - An object containing the details for the email.
2823
+ * - `to`: The recipient's email address or an array of addresses.
2824
+ * - `subject`: The subject line of the email.
2825
+ * - `html`: The HTML body of the email. For best results across all email
2826
+ * clients (like Gmail, Outlook), use inline CSS and table-based layouts.
2827
+ * - `text`: A plain-text version of the email body (optional).
2828
+ * - `from`: A custom sender name (e.g., "Acme Inc"). The email address will
2829
+ * be auto-generated by the project (e.g., "noreply@project.blink-email.com").
2830
+ * - `replyTo`: An email address for recipients to reply to (optional).
2831
+ * - `cc`: A CC recipient's email address or an array of addresses (optional).
2832
+ * - `bcc`: A BCC recipient's email address or an array of addresses (optional).
2833
+ * - `attachments`: An array of objects for files to attach, each with a `url`.
2834
+ * The file at the URL will be fetched and attached by the server.
2835
+ *
2836
+ * @example
2837
+ * ```ts
2838
+ * // Send a simple email
2839
+ * const { success, messageId } = await blink.notifications.email({
2840
+ * to: 'customer@example.com',
2841
+ * subject: 'Your order has shipped!',
2842
+ * html: '<h1>Order Confirmation</h1><p>Your order #12345 is on its way.</p>'
2843
+ * });
2844
+ *
2845
+ * // Send an email with attachments and a custom from name
2846
+ * const { success } = await blink.notifications.email({
2847
+ * to: ['team@example.com', 'manager@example.com'],
2848
+ * subject: 'New Invoice',
2849
+ * from: 'Blink Invoicing',
2850
+ * html: '<p>Please find the invoice attached.</p>',
2851
+ * attachments: [
2852
+ * { url: 'https://example.com/invoice.pdf', filename: 'invoice.pdf' }
2853
+ * ]
2854
+ * });
2855
+ * ```
2856
+ *
2857
+ * @returns A promise that resolves with an object containing the status of the email send.
2858
+ * - `success`: A boolean indicating if the email was sent successfully.
2859
+ * - `messageId`: The unique ID of the message from the email provider.
2860
+ */
2861
+ async email(params) {
2862
+ try {
2863
+ if (!params.to || !params.subject || !params.html && !params.text) {
2864
+ throw new BlinkNotificationsError('The "to", "subject", and either "html" or "text" fields are required.');
2865
+ }
2866
+ const response = await this.httpClient.post("/notifications/email", params);
2867
+ if (!response.data || typeof response.data.success !== "boolean") {
2868
+ throw new BlinkNotificationsError("Invalid response from email API");
2869
+ }
2870
+ return response.data;
2871
+ } catch (error) {
2872
+ if (error instanceof BlinkNotificationsError) {
2873
+ throw error;
2874
+ }
2875
+ const errorMessage = error.response?.data?.error?.message || error.message || "An unknown error occurred";
2876
+ throw new BlinkNotificationsError(`Failed to send email: ${errorMessage}`, error.response?.status, error.response?.data?.error);
2877
+ }
2878
+ }
2879
+ };
2880
+
2808
2881
  // src/client.ts
2809
2882
  var BlinkClientImpl = class {
2810
2883
  auth;
@@ -2813,6 +2886,7 @@ var BlinkClientImpl = class {
2813
2886
  ai;
2814
2887
  data;
2815
2888
  realtime;
2889
+ notifications;
2816
2890
  httpClient;
2817
2891
  constructor(config) {
2818
2892
  this.auth = new BlinkAuth(config);
@@ -2826,6 +2900,7 @@ var BlinkClientImpl = class {
2826
2900
  this.ai = new BlinkAIImpl(this.httpClient);
2827
2901
  this.data = new BlinkDataImpl(this.httpClient, config.projectId);
2828
2902
  this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
2903
+ this.notifications = new BlinkNotificationsImpl(this.httpClient);
2829
2904
  }
2830
2905
  };
2831
2906
  function createClient(config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.6.2",
4
- "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth for modern SaaS/AI apps",
3
+ "version": "0.7.1",
4
+ "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",
7
7
  "sdk",
@@ -10,6 +10,8 @@
10
10
  "database",
11
11
  "ai",
12
12
  "storage",
13
+ "notifications",
14
+ "email",
13
15
  "crud",
14
16
  "client"
15
17
  ],