@blinkdotnew/sdk 0.12.0 → 0.12.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/dist/index.js CHANGED
@@ -1314,6 +1314,28 @@ 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
+ return value;
1322
+ }
1323
+ function castSQLiteRecord(record) {
1324
+ if (record === null || record === void 0) {
1325
+ return record;
1326
+ }
1327
+ if (Array.isArray(record)) {
1328
+ return record.map((item) => castSQLiteRecord(item));
1329
+ }
1330
+ if (typeof record === "object") {
1331
+ const casted = {};
1332
+ for (const [key, value] of Object.entries(record)) {
1333
+ casted[key] = castSQLiteValue(value);
1334
+ }
1335
+ return casted;
1336
+ }
1337
+ return castSQLiteValue(record);
1338
+ }
1317
1339
  var BlinkTable = class {
1318
1340
  constructor(tableName, httpClient) {
1319
1341
  this.tableName = tableName;
@@ -1332,7 +1354,7 @@ var BlinkTable = class {
1332
1354
  if (!result) {
1333
1355
  throw new Error("Failed to create record");
1334
1356
  }
1335
- return result;
1357
+ return castSQLiteRecord(result);
1336
1358
  }
1337
1359
  /**
1338
1360
  * Create multiple records
@@ -1343,7 +1365,8 @@ var BlinkTable = class {
1343
1365
  data,
1344
1366
  { returning: options.returning !== false }
1345
1367
  );
1346
- return Array.isArray(response.data) ? response.data : [response.data];
1368
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1369
+ return castSQLiteRecord(records);
1347
1370
  }
1348
1371
  /**
1349
1372
  * Upsert a single record (insert or update on conflict)
@@ -1368,7 +1391,7 @@ var BlinkTable = class {
1368
1391
  if (!result) {
1369
1392
  throw new Error("Failed to upsert record");
1370
1393
  }
1371
- return result;
1394
+ return castSQLiteRecord(result);
1372
1395
  }
1373
1396
  /**
1374
1397
  * Upsert multiple records
@@ -1389,7 +1412,8 @@ var BlinkTable = class {
1389
1412
  headers
1390
1413
  }
1391
1414
  );
1392
- return Array.isArray(response.data) ? response.data : [response.data];
1415
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1416
+ return castSQLiteRecord(records);
1393
1417
  }
1394
1418
  /**
1395
1419
  * Get a single record by ID
@@ -1401,7 +1425,10 @@ var BlinkTable = class {
1401
1425
  };
1402
1426
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1403
1427
  const records = response.data;
1404
- return records.length > 0 ? records[0] : null;
1428
+ if (records.length === 0) {
1429
+ return null;
1430
+ }
1431
+ return castSQLiteRecord(records[0]);
1405
1432
  }
1406
1433
  /**
1407
1434
  * List records with filtering, sorting, and pagination
@@ -1410,7 +1437,8 @@ var BlinkTable = class {
1410
1437
  const queryParams = buildQuery(options);
1411
1438
  const searchParams = queryParams;
1412
1439
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1413
- return response.data;
1440
+ const records = response.data;
1441
+ return castSQLiteRecord(records);
1414
1442
  }
1415
1443
  /**
1416
1444
  * Update a single record by ID
@@ -1429,7 +1457,7 @@ var BlinkTable = class {
1429
1457
  if (!records || records.length === 0) {
1430
1458
  throw new Error(`Record with id ${id} not found`);
1431
1459
  }
1432
- return records[0];
1460
+ return castSQLiteRecord(records[0]);
1433
1461
  }
1434
1462
  /**
1435
1463
  * Update multiple records
package/dist/index.mjs CHANGED
@@ -1312,6 +1312,28 @@ 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
+ return value;
1320
+ }
1321
+ function castSQLiteRecord(record) {
1322
+ if (record === null || record === void 0) {
1323
+ return record;
1324
+ }
1325
+ if (Array.isArray(record)) {
1326
+ return record.map((item) => castSQLiteRecord(item));
1327
+ }
1328
+ if (typeof record === "object") {
1329
+ const casted = {};
1330
+ for (const [key, value] of Object.entries(record)) {
1331
+ casted[key] = castSQLiteValue(value);
1332
+ }
1333
+ return casted;
1334
+ }
1335
+ return castSQLiteValue(record);
1336
+ }
1315
1337
  var BlinkTable = class {
1316
1338
  constructor(tableName, httpClient) {
1317
1339
  this.tableName = tableName;
@@ -1330,7 +1352,7 @@ var BlinkTable = class {
1330
1352
  if (!result) {
1331
1353
  throw new Error("Failed to create record");
1332
1354
  }
1333
- return result;
1355
+ return castSQLiteRecord(result);
1334
1356
  }
1335
1357
  /**
1336
1358
  * Create multiple records
@@ -1341,7 +1363,8 @@ var BlinkTable = class {
1341
1363
  data,
1342
1364
  { returning: options.returning !== false }
1343
1365
  );
1344
- return Array.isArray(response.data) ? response.data : [response.data];
1366
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1367
+ return castSQLiteRecord(records);
1345
1368
  }
1346
1369
  /**
1347
1370
  * Upsert a single record (insert or update on conflict)
@@ -1366,7 +1389,7 @@ var BlinkTable = class {
1366
1389
  if (!result) {
1367
1390
  throw new Error("Failed to upsert record");
1368
1391
  }
1369
- return result;
1392
+ return castSQLiteRecord(result);
1370
1393
  }
1371
1394
  /**
1372
1395
  * Upsert multiple records
@@ -1387,7 +1410,8 @@ var BlinkTable = class {
1387
1410
  headers
1388
1411
  }
1389
1412
  );
1390
- return Array.isArray(response.data) ? response.data : [response.data];
1413
+ const records = Array.isArray(response.data) ? response.data : [response.data];
1414
+ return castSQLiteRecord(records);
1391
1415
  }
1392
1416
  /**
1393
1417
  * Get a single record by ID
@@ -1399,7 +1423,10 @@ var BlinkTable = class {
1399
1423
  };
1400
1424
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1401
1425
  const records = response.data;
1402
- return records.length > 0 ? records[0] : null;
1426
+ if (records.length === 0) {
1427
+ return null;
1428
+ }
1429
+ return castSQLiteRecord(records[0]);
1403
1430
  }
1404
1431
  /**
1405
1432
  * List records with filtering, sorting, and pagination
@@ -1408,7 +1435,8 @@ var BlinkTable = class {
1408
1435
  const queryParams = buildQuery(options);
1409
1436
  const searchParams = queryParams;
1410
1437
  const response = await this.httpClient.dbGet(this.tableName, searchParams);
1411
- return response.data;
1438
+ const records = response.data;
1439
+ return castSQLiteRecord(records);
1412
1440
  }
1413
1441
  /**
1414
1442
  * Update a single record by ID
@@ -1427,7 +1455,7 @@ var BlinkTable = class {
1427
1455
  if (!records || records.length === 0) {
1428
1456
  throw new Error(`Record with id ${id} not found`);
1429
1457
  }
1430
- return records[0];
1458
+ return castSQLiteRecord(records[0]);
1431
1459
  }
1432
1460
  /**
1433
1461
  * Update multiple records
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.12.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",