@blinkdotnew/sdk 0.11.2 → 0.12.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/dist/index.js CHANGED
@@ -1314,6 +1314,34 @@ var BlinkAuth = class {
1314
1314
  };
1315
1315
 
1316
1316
  // src/database.ts
1317
+ function castSQLiteValue(value) {
1318
+ if (value && typeof value === "object" && value.type === "null") {
1319
+ return null;
1320
+ }
1321
+ if (value === "0" || value === 0) {
1322
+ return false;
1323
+ }
1324
+ if (value === "1" || value === 1) {
1325
+ return true;
1326
+ }
1327
+ return value;
1328
+ }
1329
+ function castSQLiteRecord(record) {
1330
+ if (record === null || record === void 0) {
1331
+ return record;
1332
+ }
1333
+ if (Array.isArray(record)) {
1334
+ return record.map((item) => castSQLiteRecord(item));
1335
+ }
1336
+ if (typeof record === "object") {
1337
+ const casted = {};
1338
+ for (const [key, value] of Object.entries(record)) {
1339
+ casted[key] = castSQLiteValue(value);
1340
+ }
1341
+ return casted;
1342
+ }
1343
+ return castSQLiteValue(record);
1344
+ }
1317
1345
  var BlinkTable = class {
1318
1346
  constructor(tableName, httpClient) {
1319
1347
  this.tableName = tableName;
@@ -1332,7 +1360,7 @@ var BlinkTable = class {
1332
1360
  if (!result) {
1333
1361
  throw new Error("Failed to create record");
1334
1362
  }
1335
- return result;
1363
+ return castSQLiteRecord(result);
1336
1364
  }
1337
1365
  /**
1338
1366
  * Create multiple records
@@ -1343,7 +1371,8 @@ var BlinkTable = class {
1343
1371
  data,
1344
1372
  { returning: options.returning !== false }
1345
1373
  );
1346
- return Array.isArray(response.data) ? response.data : [response.data];
1374
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1375
+ return castSQLiteRecord(records);
1347
1376
  }
1348
1377
  /**
1349
1378
  * Upsert a single record (insert or update on conflict)
@@ -1368,7 +1397,7 @@ var BlinkTable = class {
1368
1397
  if (!result) {
1369
1398
  throw new Error("Failed to upsert record");
1370
1399
  }
1371
- return result;
1400
+ return castSQLiteRecord(result);
1372
1401
  }
1373
1402
  /**
1374
1403
  * Upsert multiple records
@@ -1389,7 +1418,8 @@ var BlinkTable = class {
1389
1418
  headers
1390
1419
  }
1391
1420
  );
1392
- return Array.isArray(response.data) ? response.data : [response.data];
1421
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1422
+ return castSQLiteRecord(records);
1393
1423
  }
1394
1424
  /**
1395
1425
  * Get a single record by ID
@@ -1401,7 +1431,10 @@ var BlinkTable = class {
1401
1431
  };
1402
1432
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1403
1433
  const records = response.data;
1404
- return records.length > 0 ? records[0] : null;
1434
+ if (records.length === 0) {
1435
+ return null;
1436
+ }
1437
+ return castSQLiteRecord(records[0]);
1405
1438
  }
1406
1439
  /**
1407
1440
  * List records with filtering, sorting, and pagination
@@ -1411,7 +1444,7 @@ var BlinkTable = class {
1411
1444
  const searchParams = queryParams;
1412
1445
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1413
1446
  const records = response.data;
1414
- return records;
1447
+ return castSQLiteRecord(records);
1415
1448
  }
1416
1449
  /**
1417
1450
  * Update a single record by ID
@@ -1430,7 +1463,7 @@ var BlinkTable = class {
1430
1463
  if (!records || records.length === 0) {
1431
1464
  throw new Error(`Record with id ${id} not found`);
1432
1465
  }
1433
- return records[0];
1466
+ return castSQLiteRecord(records[0]);
1434
1467
  }
1435
1468
  /**
1436
1469
  * Update multiple records
@@ -1486,7 +1519,8 @@ var BlinkTable = class {
1486
1519
  return parseInt(match[1], 10);
1487
1520
  }
1488
1521
  }
1489
- return Array.isArray(response.data) ? response.data.length : 0;
1522
+ const records = response.data;
1523
+ return records.length;
1490
1524
  }
1491
1525
  /**
1492
1526
  * Check if any records exist matching filter
package/dist/index.mjs CHANGED
@@ -1312,6 +1312,34 @@ var BlinkAuth = class {
1312
1312
  };
1313
1313
 
1314
1314
  // src/database.ts
1315
+ function castSQLiteValue(value) {
1316
+ if (value && typeof value === "object" && value.type === "null") {
1317
+ return null;
1318
+ }
1319
+ if (value === "0" || value === 0) {
1320
+ return false;
1321
+ }
1322
+ if (value === "1" || value === 1) {
1323
+ return true;
1324
+ }
1325
+ return value;
1326
+ }
1327
+ function castSQLiteRecord(record) {
1328
+ if (record === null || record === void 0) {
1329
+ return record;
1330
+ }
1331
+ if (Array.isArray(record)) {
1332
+ return record.map((item) => castSQLiteRecord(item));
1333
+ }
1334
+ if (typeof record === "object") {
1335
+ const casted = {};
1336
+ for (const [key, value] of Object.entries(record)) {
1337
+ casted[key] = castSQLiteValue(value);
1338
+ }
1339
+ return casted;
1340
+ }
1341
+ return castSQLiteValue(record);
1342
+ }
1315
1343
  var BlinkTable = class {
1316
1344
  constructor(tableName, httpClient) {
1317
1345
  this.tableName = tableName;
@@ -1330,7 +1358,7 @@ var BlinkTable = class {
1330
1358
  if (!result) {
1331
1359
  throw new Error("Failed to create record");
1332
1360
  }
1333
- return result;
1361
+ return castSQLiteRecord(result);
1334
1362
  }
1335
1363
  /**
1336
1364
  * Create multiple records
@@ -1341,7 +1369,8 @@ var BlinkTable = class {
1341
1369
  data,
1342
1370
  { returning: options.returning !== false }
1343
1371
  );
1344
- return Array.isArray(response.data) ? response.data : [response.data];
1372
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1373
+ return castSQLiteRecord(records);
1345
1374
  }
1346
1375
  /**
1347
1376
  * Upsert a single record (insert or update on conflict)
@@ -1366,7 +1395,7 @@ var BlinkTable = class {
1366
1395
  if (!result) {
1367
1396
  throw new Error("Failed to upsert record");
1368
1397
  }
1369
- return result;
1398
+ return castSQLiteRecord(result);
1370
1399
  }
1371
1400
  /**
1372
1401
  * Upsert multiple records
@@ -1387,7 +1416,8 @@ var BlinkTable = class {
1387
1416
  headers
1388
1417
  }
1389
1418
  );
1390
- return Array.isArray(response.data) ? response.data : [response.data];
1419
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1420
+ return castSQLiteRecord(records);
1391
1421
  }
1392
1422
  /**
1393
1423
  * Get a single record by ID
@@ -1399,7 +1429,10 @@ var BlinkTable = class {
1399
1429
  };
1400
1430
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1401
1431
  const records = response.data;
1402
- return records.length > 0 ? records[0] : null;
1432
+ if (records.length === 0) {
1433
+ return null;
1434
+ }
1435
+ return castSQLiteRecord(records[0]);
1403
1436
  }
1404
1437
  /**
1405
1438
  * List records with filtering, sorting, and pagination
@@ -1409,7 +1442,7 @@ var BlinkTable = class {
1409
1442
  const searchParams = queryParams;
1410
1443
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1411
1444
  const records = response.data;
1412
- return records;
1445
+ return castSQLiteRecord(records);
1413
1446
  }
1414
1447
  /**
1415
1448
  * Update a single record by ID
@@ -1428,7 +1461,7 @@ var BlinkTable = class {
1428
1461
  if (!records || records.length === 0) {
1429
1462
  throw new Error(`Record with id ${id} not found`);
1430
1463
  }
1431
- return records[0];
1464
+ return castSQLiteRecord(records[0]);
1432
1465
  }
1433
1466
  /**
1434
1467
  * Update multiple records
@@ -1484,7 +1517,8 @@ var BlinkTable = class {
1484
1517
  return parseInt(match[1], 10);
1485
1518
  }
1486
1519
  }
1487
- return Array.isArray(response.data) ? response.data.length : 0;
1520
+ const records = response.data;
1521
+ return records.length;
1488
1522
  }
1489
1523
  /**
1490
1524
  * Check if any records exist matching filter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.11.2",
3
+ "version": "0.12.1",
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",