@tspvivek/baasix-sdk 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +70 -18
- package/dist/index.cjs +264 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -62
- package/dist/index.d.ts +196 -62
- package/dist/index.js +264 -122
- package/dist/index.js.map +1 -1
- package/dist/modules/files.cjs +34 -1
- package/dist/modules/files.cjs.map +1 -1
- package/dist/modules/files.js +34 -1
- package/dist/modules/files.js.map +1 -1
- package/dist/modules/items.cjs +58 -40
- package/dist/modules/items.cjs.map +1 -1
- package/dist/modules/items.d.cts +11 -18
- package/dist/modules/items.d.ts +11 -18
- package/dist/modules/items.js +58 -40
- package/dist/modules/items.js.map +1 -1
- package/dist/modules/schemas.cjs +55 -2
- package/dist/modules/schemas.cjs.map +1 -1
- package/dist/modules/schemas.d.cts +23 -2
- package/dist/modules/schemas.d.ts +23 -2
- package/dist/modules/schemas.js +55 -2
- package/dist/modules/schemas.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ Official JavaScript/TypeScript SDK for [Baasix](https://www.baasix.com) Backend-
|
|
|
20
20
|
- 🔀 **Workflows** - Execute and monitor workflow executions
|
|
21
21
|
- 👥 **User & Role Management** - Admin operations for users and roles
|
|
22
22
|
- 📊 **Reports** - Generate reports with aggregations
|
|
23
|
+
- 🔔 **Notifications** - User notification system with realtime delivery
|
|
24
|
+
- 🗃️ **Migrations** - Database schema migration management
|
|
25
|
+
- 🔃 **Sort/Reorder** - Drag-and-drop style item reordering
|
|
23
26
|
|
|
24
27
|
## Installation
|
|
25
28
|
|
|
@@ -716,22 +719,36 @@ await baasix.roles.update(roleId, { description: 'Updated description' });
|
|
|
716
719
|
|
|
717
720
|
```typescript
|
|
718
721
|
// Import from CSV file
|
|
719
|
-
const result = await baasix.items('products').importCSV(csvFile
|
|
720
|
-
|
|
721
|
-
skipFirstRow: true,
|
|
722
|
-
});
|
|
723
|
-
console.log(`Created: ${result.created}, Errors: ${result.errors.length}`);
|
|
722
|
+
const result = await baasix.items('products').importCSV(csvFile);
|
|
723
|
+
console.log(`Imported: ${result.imported}, Failed: ${result.failed}`);
|
|
724
724
|
|
|
725
725
|
// Import from JSON file
|
|
726
726
|
const result = await baasix.items('products').importJSON(jsonFile);
|
|
727
727
|
|
|
728
|
-
//
|
|
729
|
-
const
|
|
728
|
+
// Bulk create from data array
|
|
729
|
+
const ids = await baasix.items('products').createMany([
|
|
730
730
|
{ name: 'Product 1', price: 29.99 },
|
|
731
731
|
{ name: 'Product 2', price: 39.99 },
|
|
732
732
|
]);
|
|
733
733
|
```
|
|
734
734
|
|
|
735
|
+
## Sort / Reorder Items
|
|
736
|
+
|
|
737
|
+
```typescript
|
|
738
|
+
// Move item1 before item2
|
|
739
|
+
await baasix.items('products').sortItem('item1-uuid', 'item2-uuid');
|
|
740
|
+
|
|
741
|
+
// Move item1 after item2
|
|
742
|
+
await baasix.items('products').sortItem('item1-uuid', 'item2-uuid', 'after');
|
|
743
|
+
|
|
744
|
+
// Reorder multiple items (set explicit order)
|
|
745
|
+
await baasix.items('products').reorder([
|
|
746
|
+
'item3-uuid',
|
|
747
|
+
'item1-uuid',
|
|
748
|
+
'item2-uuid'
|
|
749
|
+
]);
|
|
750
|
+
```
|
|
751
|
+
|
|
735
752
|
## Migrations (Admin)
|
|
736
753
|
|
|
737
754
|
```typescript
|
|
@@ -739,31 +756,66 @@ const result = await baasix.items('products').importData([
|
|
|
739
756
|
const status = await baasix.migrations.status();
|
|
740
757
|
console.log(`Pending: ${status.pendingCount}`);
|
|
741
758
|
|
|
759
|
+
// Get pending migrations
|
|
760
|
+
const pending = await baasix.migrations.pending();
|
|
761
|
+
|
|
742
762
|
// Run pending migrations
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
763
|
+
const result = await baasix.migrations.run();
|
|
764
|
+
console.log(`Completed: ${result.summary.completed}`);
|
|
765
|
+
|
|
766
|
+
// Run with options
|
|
767
|
+
const result = await baasix.migrations.run({
|
|
768
|
+
step: 1, // Run only 1 migration
|
|
769
|
+
dryRun: true, // Preview without executing
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
// Rollback a specific migration
|
|
773
|
+
await baasix.migrations.rollback('20231201000000');
|
|
747
774
|
|
|
748
775
|
// Rollback last batch
|
|
749
|
-
|
|
776
|
+
await baasix.migrations.rollbackBatch();
|
|
777
|
+
|
|
778
|
+
// Create new migration file
|
|
779
|
+
const { filepath } = await baasix.migrations.create('add_status_column', {
|
|
780
|
+
type: 'schema',
|
|
781
|
+
description: 'Add status column to orders',
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// Mark migrations as completed (without running)
|
|
785
|
+
await baasix.migrations.markCompleted('20231201000000');
|
|
786
|
+
await baasix.migrations.markAllCompleted();
|
|
750
787
|
```
|
|
751
788
|
|
|
752
789
|
## Notifications
|
|
753
790
|
|
|
754
791
|
```typescript
|
|
755
|
-
// Get notifications
|
|
792
|
+
// Get user notifications
|
|
756
793
|
const { data } = await baasix.notifications.find({
|
|
757
794
|
limit: 20,
|
|
758
|
-
seen: false,
|
|
795
|
+
filter: { seen: { eq: false } },
|
|
759
796
|
});
|
|
760
797
|
|
|
761
|
-
// Mark as seen
|
|
762
|
-
await baasix.notifications.markAsSeen('notification-uuid');
|
|
763
|
-
await baasix.notifications.markAllSeen();
|
|
764
|
-
|
|
765
798
|
// Get unread count
|
|
766
799
|
const count = await baasix.notifications.getUnreadCount();
|
|
800
|
+
|
|
801
|
+
// Mark notifications as seen
|
|
802
|
+
await baasix.notifications.markAsSeen(['id1', 'id2']);
|
|
803
|
+
// Or mark all as seen
|
|
804
|
+
await baasix.notifications.markAsSeen();
|
|
805
|
+
|
|
806
|
+
// Delete notifications
|
|
807
|
+
await baasix.notifications.delete(['id1', 'id2']);
|
|
808
|
+
|
|
809
|
+
// Send notification (admin only)
|
|
810
|
+
await baasix.notifications.send({
|
|
811
|
+
type: 'alert',
|
|
812
|
+
title: 'System Update',
|
|
813
|
+
message: 'Maintenance scheduled for tonight',
|
|
814
|
+
userIds: ['user1-uuid', 'user2-uuid'],
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
// Cleanup old notifications (admin only)
|
|
818
|
+
await baasix.notifications.cleanup(30); // older than 30 days
|
|
767
819
|
```
|
|
768
820
|
|
|
769
821
|
## Custom Storage Adapter
|