@baasix/sdk 0.1.13 → 0.1.15

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 CHANGED
@@ -463,6 +463,8 @@ Baasix supports 50+ filter operators:
463
463
 
464
464
  // Dynamic variables
465
465
  { author_Id: { eq: '$CURRENT_USER' } }
466
+ { tenant_Id: { eq: '$CURRENT_TENANT' } }
467
+ { currency: { eq: '$CURRENT_SETTINGS.currency' } }
466
468
  { createdAt: { gte: '$NOW-DAYS_30' } }
467
469
  ```
468
470
 
@@ -736,16 +738,20 @@ const report = await baasix.reports.generate('orders', {
736
738
  },
737
739
  groupBy: ['category'],
738
740
  filter: { status: { eq: 'completed' } },
741
+ sort: ['-revenue'], // Sort by aggregate alias descending
742
+ limit: 10, // Paginate grouped results
743
+ page: 1,
739
744
  dateRange: {
740
745
  start: '2025-01-01',
741
746
  end: '2025-12-31',
742
747
  },
743
748
  });
749
+ // Returns: { data: [...], totalCount: 15 }
744
750
  ```
745
751
 
746
752
  ### Query Report (GET)
747
753
 
748
- Use `query()` to fetch a report with a GET request, sending parameters as query strings:
754
+ Use `query()` to fetch a report with query parameters:
749
755
 
750
756
  ```typescript
751
757
  const report = await baasix.reports.query('orders', {
@@ -754,7 +760,11 @@ const report = await baasix.reports.query('orders', {
754
760
  },
755
761
  groupBy: ['status'],
756
762
  filter: { createdAt: { gte: '$NOW-DAYS_30' } },
763
+ sort: ['-total'], // Sort by aggregate result
764
+ limit: 50,
765
+ page: 1,
757
766
  });
767
+ // Returns: { data: [...], totalCount: 5 }
758
768
  ```
759
769
 
760
770
  ### Multi-Collection Stats
@@ -811,6 +821,9 @@ const results = await baasix.reports.aggregate('orders', {
811
821
  },
812
822
  groupBy: ['status', 'paymentMethod'],
813
823
  filter: { createdAt: { gte: '$NOW-DAYS_30' } },
824
+ sort: ['-total'], // Sort by aggregate alias
825
+ limit: 20, // Paginate results
826
+ page: 1,
814
827
  });
815
828
  ```
816
829
 
package/dist/index.cjs CHANGED
@@ -2883,7 +2883,9 @@ var ReportsModule = class {
2883
2883
  aggregate: options.aggregate,
2884
2884
  groupBy: options.groupBy,
2885
2885
  filter: options.filter,
2886
- limit: -1
2886
+ sort: options.sort,
2887
+ limit: options.limit ?? -1,
2888
+ page: options.page
2887
2889
  }
2888
2890
  }
2889
2891
  );