@blinkdotnew/sdk 0.13.0 → 0.13.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.
Files changed (2) hide show
  1. package/README.md +51 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -216,6 +216,11 @@ const todos = await blink.db.todos.list({
216
216
  })
217
217
  // `todos` is a direct array: Todo[]
218
218
 
219
+ // Note: Boolean fields are returned as "0"/"1" strings from SQLite
220
+ // Check boolean values using Number(value) > 0
221
+ const completedTodos = todos.filter(todo => Number(todo.completed) > 0)
222
+ const incompleteTodos = todos.filter(todo => Number(todo.completed) === 0)
223
+
219
224
  // Update
220
225
  await blink.db.todos.update(todo.id, { completed: true })
221
226
 
@@ -296,6 +301,42 @@ const { object } = await blink.ai.generateObject({
296
301
  }
297
302
  })
298
303
 
304
+ // ⚠️ IMPORTANT: Schema Rule for generateObject()
305
+ // The top-level schema MUST use type: "object" - you cannot use type: "array" at the top level
306
+ // This ensures clear, robust, and extensible API calls with named parameters
307
+
308
+ // ✅ Correct: Array inside object
309
+ const { object: todoList } = await blink.ai.generateObject({
310
+ prompt: 'Generate a list of 5 daily tasks',
311
+ schema: {
312
+ type: 'object',
313
+ properties: {
314
+ tasks: {
315
+ type: 'array',
316
+ items: {
317
+ type: 'object',
318
+ properties: {
319
+ title: { type: 'string' },
320
+ priority: { type: 'string', enum: ['low', 'medium', 'high'] }
321
+ }
322
+ }
323
+ }
324
+ },
325
+ required: ['tasks']
326
+ }
327
+ })
328
+ // Result: { tasks: [{ title: "Exercise", priority: "high" }, ...] }
329
+
330
+ // ❌ Wrong: Top-level array (will fail)
331
+ // const { object } = await blink.ai.generateObject({
332
+ // prompt: 'Generate tasks',
333
+ // schema: {
334
+ // type: 'array', // ❌ This will throw an error
335
+ // items: { type: 'string' }
336
+ // }
337
+ // })
338
+ // Error: "schema must be a JSON Schema of 'type: \"object\"', got 'type: \"array\"'"
339
+
299
340
  // Image generation
300
341
  const { data } = await blink.ai.generateImage({
301
342
  prompt: 'A serene landscape',
@@ -1151,17 +1192,22 @@ The SDK is written in TypeScript and provides full type safety:
1151
1192
  interface Todo {
1152
1193
  id: string
1153
1194
  title: string
1154
- completed: boolean
1195
+ completed: boolean // Will be returned as "0" or "1" string from SQLite
1155
1196
  user_id: string
1156
1197
  created_at: string
1157
1198
  }
1158
1199
 
1159
- // Note: Boolean fields are stored as integers (0/1) in SQLite
1200
+ // Note: Boolean fields are returned as "0"/"1" strings from SQLite
1160
1201
  // Use Number(value) > 0 to check boolean values
1161
- const completed = Number(todo.completed) > 0
1202
+ const todos = await blink.db.todos.list<Todo>()
1203
+
1204
+ // Check boolean values properly
1205
+ const completedTodos = todos.filter(todo => Number(todo.completed) > 0)
1206
+ const incompleteTodos = todos.filter(todo => Number(todo.completed) === 0)
1162
1207
 
1163
- const todos = await blink.db.todos.list<Todo>({
1164
- where: { completed: false }
1208
+ // When filtering by boolean values in queries, use "0"/"1" strings
1209
+ const onlyCompleted = await blink.db.todos.list<Todo>({
1210
+ where: { completed: "1" } // Use string "1" for true, "0" for false
1165
1211
  })
1166
1212
  // todos is fully typed as Todo[]
1167
1213
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",