@blinkdotnew/sdk 0.2.1 → 0.2.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 +47 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,11 @@ const { text } = await blink.ai.generateText({
|
|
|
45
45
|
prompt: "Write a summary of the user's todos"
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
+
// Data operations (extract text from documents)
|
|
49
|
+
const { chunks } = await blink.data.extractFromUrl(
|
|
50
|
+
"https://example.com/document.pdf"
|
|
51
|
+
)
|
|
52
|
+
|
|
48
53
|
// Storage operations (instant - returns public URL directly)
|
|
49
54
|
const { publicUrl } = await blink.storage.upload(
|
|
50
55
|
file,
|
|
@@ -69,6 +74,7 @@ This SDK powers every Blink-generated app with:
|
|
|
69
74
|
- **🔐 Authentication**: JWT-based auth with automatic token management
|
|
70
75
|
- **🗄️ Database**: PostgREST-compatible CRUD operations with advanced filtering
|
|
71
76
|
- **🤖 AI**: Text generation, object generation, image creation, speech synthesis, and transcription
|
|
77
|
+
- **📄 Data**: Extract text content from documents, spreadsheets, and more
|
|
72
78
|
- **📁 Storage**: File upload, download, and management
|
|
73
79
|
- **🌐 Universal**: Works on client-side and server-side
|
|
74
80
|
- **📱 Framework Agnostic**: React, Vue, Svelte, vanilla JS, Node.js, Deno
|
|
@@ -241,6 +247,46 @@ await blink.ai.streamText(
|
|
|
241
247
|
)
|
|
242
248
|
```
|
|
243
249
|
|
|
250
|
+
### Data Operations
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
// Simple text extraction (default - returns single string)
|
|
254
|
+
const text = await blink.data.extractFromUrl('https://example.com/document.pdf');
|
|
255
|
+
console.log(typeof text); // 'string'
|
|
256
|
+
|
|
257
|
+
// Extract with chunking enabled
|
|
258
|
+
const chunks = await blink.data.extractFromUrl('https://example.com/document.pdf', {
|
|
259
|
+
chunking: true,
|
|
260
|
+
chunkSize: 2000
|
|
261
|
+
});
|
|
262
|
+
console.log(Array.isArray(chunks)); // true
|
|
263
|
+
|
|
264
|
+
// Extract from different file types
|
|
265
|
+
const csvText = await blink.data.extractFromUrl('https://example.com/data.csv');
|
|
266
|
+
const htmlText = await blink.data.extractFromUrl('https://example.com/page.html');
|
|
267
|
+
const jsonText = await blink.data.extractFromUrl('https://example.com/config.json');
|
|
268
|
+
|
|
269
|
+
// Extract from uploaded file blob (simple)
|
|
270
|
+
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
|
|
271
|
+
const file = fileInput.files[0];
|
|
272
|
+
const extractedText = await blink.data.extractFromBlob(file);
|
|
273
|
+
|
|
274
|
+
// Extract from uploaded file blob (with chunking)
|
|
275
|
+
const chunks = await blink.data.extractFromBlob(file, {
|
|
276
|
+
chunking: true,
|
|
277
|
+
chunkSize: 3000
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// Error handling for data extraction
|
|
281
|
+
try {
|
|
282
|
+
const result = await blink.data.extractFromUrl('https://example.com/huge-file.pdf');
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (error instanceof BlinkDataError) {
|
|
285
|
+
console.error('Data processing error:', error.message);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
244
290
|
### Storage Operations
|
|
245
291
|
|
|
246
292
|
```typescript
|
|
@@ -263,7 +309,7 @@ await blink.storage.remove('file1.jpg', 'file2.jpg')
|
|
|
263
309
|
### Error Handling
|
|
264
310
|
|
|
265
311
|
```typescript
|
|
266
|
-
import { BlinkAuthError, BlinkAIError, BlinkStorageError } from '@blinkdotnew/sdk'
|
|
312
|
+
import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError } from '@blinkdotnew/sdk'
|
|
267
313
|
|
|
268
314
|
try {
|
|
269
315
|
const user = await blink.auth.me()
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
|
|
2
|
-
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkStorage, BlinkUser, CreateOptions, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, BlinkData, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, DataExtraction } from '@blink/core';
|
|
2
|
+
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Blink Auth Module - Client-side authentication management
|
|
@@ -206,6 +206,7 @@ interface BlinkClient {
|
|
|
206
206
|
db: BlinkDatabase;
|
|
207
207
|
storage: BlinkStorage;
|
|
208
208
|
ai: BlinkAI;
|
|
209
|
+
data: BlinkData;
|
|
209
210
|
}
|
|
210
211
|
/**
|
|
211
212
|
* Create a new Blink client instance
|
|
@@ -596,4 +597,10 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
596
597
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
597
598
|
}
|
|
598
599
|
|
|
599
|
-
|
|
600
|
+
declare class BlinkDataImpl implements BlinkData {
|
|
601
|
+
private httpClient;
|
|
602
|
+
constructor(httpClient: HttpClient);
|
|
603
|
+
extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
|
|
2
|
-
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkStorage, BlinkUser, CreateOptions, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, BlinkData, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, DataExtraction } from '@blink/core';
|
|
2
|
+
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Blink Auth Module - Client-side authentication management
|
|
@@ -206,6 +206,7 @@ interface BlinkClient {
|
|
|
206
206
|
db: BlinkDatabase;
|
|
207
207
|
storage: BlinkStorage;
|
|
208
208
|
ai: BlinkAI;
|
|
209
|
+
data: BlinkData;
|
|
209
210
|
}
|
|
210
211
|
/**
|
|
211
212
|
* Create a new Blink client instance
|
|
@@ -596,4 +597,10 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
596
597
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
597
598
|
}
|
|
598
599
|
|
|
599
|
-
|
|
600
|
+
declare class BlinkDataImpl implements BlinkData {
|
|
601
|
+
private httpClient;
|
|
602
|
+
constructor(httpClient: HttpClient);
|
|
603
|
+
extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,12 @@ var BlinkAIError = class extends BlinkError {
|
|
|
40
40
|
this.name = "BlinkAIError";
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
var BlinkDataError = class extends BlinkError {
|
|
44
|
+
constructor(message, status, details) {
|
|
45
|
+
super(message, "DATA_ERROR", status, details);
|
|
46
|
+
this.name = "BlinkDataError";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
43
49
|
|
|
44
50
|
// ../core/src/query-builder.ts
|
|
45
51
|
function buildFilterQuery(condition) {
|
|
@@ -529,6 +535,15 @@ var HttpClient = class {
|
|
|
529
535
|
signal
|
|
530
536
|
});
|
|
531
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Data-specific requests
|
|
540
|
+
*/
|
|
541
|
+
async dataExtractFromUrl(url, filename) {
|
|
542
|
+
return this.request(`/api/data/${this.projectId}/extract-from-url`, {
|
|
543
|
+
method: "POST",
|
|
544
|
+
body: { url, filename }
|
|
545
|
+
});
|
|
546
|
+
}
|
|
532
547
|
/**
|
|
533
548
|
* Private helper methods
|
|
534
549
|
*/
|
|
@@ -2279,12 +2294,41 @@ var BlinkAIImpl = class {
|
|
|
2279
2294
|
}
|
|
2280
2295
|
};
|
|
2281
2296
|
|
|
2297
|
+
// src/data.ts
|
|
2298
|
+
var BlinkDataImpl = class {
|
|
2299
|
+
constructor(httpClient) {
|
|
2300
|
+
this.httpClient = httpClient;
|
|
2301
|
+
}
|
|
2302
|
+
async extractFromUrl(url, filename) {
|
|
2303
|
+
try {
|
|
2304
|
+
const response = await this.httpClient.dataExtractFromUrl(url, filename);
|
|
2305
|
+
if (response.data?.chunks) {
|
|
2306
|
+
return {
|
|
2307
|
+
chunks: response.data.chunks
|
|
2308
|
+
};
|
|
2309
|
+
} else {
|
|
2310
|
+
throw new BlinkDataError("Invalid response format: missing chunks");
|
|
2311
|
+
}
|
|
2312
|
+
} catch (error) {
|
|
2313
|
+
if (error instanceof BlinkDataError) {
|
|
2314
|
+
throw error;
|
|
2315
|
+
}
|
|
2316
|
+
throw new BlinkDataError(
|
|
2317
|
+
`Data extraction failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2318
|
+
void 0,
|
|
2319
|
+
{ originalError: error }
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2282
2325
|
// src/client.ts
|
|
2283
2326
|
var BlinkClientImpl = class {
|
|
2284
2327
|
auth;
|
|
2285
2328
|
db;
|
|
2286
2329
|
storage;
|
|
2287
2330
|
ai;
|
|
2331
|
+
data;
|
|
2288
2332
|
httpClient;
|
|
2289
2333
|
constructor(config) {
|
|
2290
2334
|
this.auth = new BlinkAuth(config);
|
|
@@ -2296,6 +2340,7 @@ var BlinkClientImpl = class {
|
|
|
2296
2340
|
this.db = new BlinkDatabase(this.httpClient);
|
|
2297
2341
|
this.storage = new BlinkStorageImpl(this.httpClient);
|
|
2298
2342
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2343
|
+
this.data = new BlinkDataImpl(this.httpClient);
|
|
2299
2344
|
}
|
|
2300
2345
|
};
|
|
2301
2346
|
function createClient(config) {
|
|
@@ -2310,6 +2355,7 @@ function createClient(config) {
|
|
|
2310
2355
|
}
|
|
2311
2356
|
|
|
2312
2357
|
exports.BlinkAIImpl = BlinkAIImpl;
|
|
2358
|
+
exports.BlinkDataImpl = BlinkDataImpl;
|
|
2313
2359
|
exports.BlinkDatabase = BlinkDatabase;
|
|
2314
2360
|
exports.BlinkStorageImpl = BlinkStorageImpl;
|
|
2315
2361
|
exports.BlinkTable = BlinkTable;
|