@baasix/sdk 0.1.14 → 0.1.16
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 +12 -1
- package/dist/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/items.cjs +4 -1
- package/dist/modules/items.cjs.map +1 -1
- package/dist/modules/items.d.cts +3 -0
- package/dist/modules/items.d.ts +3 -0
- package/dist/modules/items.js +4 -1
- package/dist/modules/items.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -738,16 +738,20 @@ const report = await baasix.reports.generate('orders', {
|
|
|
738
738
|
},
|
|
739
739
|
groupBy: ['category'],
|
|
740
740
|
filter: { status: { eq: 'completed' } },
|
|
741
|
+
sort: ['-revenue'], // Sort by aggregate alias descending
|
|
742
|
+
limit: 10, // Paginate grouped results
|
|
743
|
+
page: 1,
|
|
741
744
|
dateRange: {
|
|
742
745
|
start: '2025-01-01',
|
|
743
746
|
end: '2025-12-31',
|
|
744
747
|
},
|
|
745
748
|
});
|
|
749
|
+
// Returns: { data: [...], totalCount: 15 }
|
|
746
750
|
```
|
|
747
751
|
|
|
748
752
|
### Query Report (GET)
|
|
749
753
|
|
|
750
|
-
Use `query()` to fetch a report with
|
|
754
|
+
Use `query()` to fetch a report with query parameters:
|
|
751
755
|
|
|
752
756
|
```typescript
|
|
753
757
|
const report = await baasix.reports.query('orders', {
|
|
@@ -756,7 +760,11 @@ const report = await baasix.reports.query('orders', {
|
|
|
756
760
|
},
|
|
757
761
|
groupBy: ['status'],
|
|
758
762
|
filter: { createdAt: { gte: '$NOW-DAYS_30' } },
|
|
763
|
+
sort: ['-total'], // Sort by aggregate result
|
|
764
|
+
limit: 50,
|
|
765
|
+
page: 1,
|
|
759
766
|
});
|
|
767
|
+
// Returns: { data: [...], totalCount: 5 }
|
|
760
768
|
```
|
|
761
769
|
|
|
762
770
|
### Multi-Collection Stats
|
|
@@ -813,6 +821,9 @@ const results = await baasix.reports.aggregate('orders', {
|
|
|
813
821
|
},
|
|
814
822
|
groupBy: ['status', 'paymentMethod'],
|
|
815
823
|
filter: { createdAt: { gte: '$NOW-DAYS_30' } },
|
|
824
|
+
sort: ['-total'], // Sort by aggregate alias
|
|
825
|
+
limit: 20, // Paginate results
|
|
826
|
+
page: 1,
|
|
816
827
|
});
|
|
817
828
|
```
|
|
818
829
|
|
package/dist/index.cjs
CHANGED
|
@@ -1570,13 +1570,16 @@ var ItemsModule = class {
|
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Restore a soft-deleted item
|
|
1572
1572
|
*
|
|
1573
|
+
* Only works for collections with `paranoid: true`. Clears the `deletedAt`
|
|
1574
|
+
* timestamp so the record reappears in normal queries.
|
|
1575
|
+
*
|
|
1573
1576
|
* @example
|
|
1574
1577
|
* ```typescript
|
|
1575
1578
|
* await items.restore('product-uuid');
|
|
1576
1579
|
* ```
|
|
1577
1580
|
*/
|
|
1578
1581
|
async restore(id) {
|
|
1579
|
-
await this.
|
|
1582
|
+
await this.client.post(`/items/${this.collection}/${id}/restore`);
|
|
1580
1583
|
}
|
|
1581
1584
|
/**
|
|
1582
1585
|
* Aggregate data with grouping
|
|
@@ -2883,7 +2886,9 @@ var ReportsModule = class {
|
|
|
2883
2886
|
aggregate: options.aggregate,
|
|
2884
2887
|
groupBy: options.groupBy,
|
|
2885
2888
|
filter: options.filter,
|
|
2886
|
-
|
|
2889
|
+
sort: options.sort,
|
|
2890
|
+
limit: options.limit ?? -1,
|
|
2891
|
+
page: options.page
|
|
2887
2892
|
}
|
|
2888
2893
|
}
|
|
2889
2894
|
);
|