@centrali-io/centrali-sdk 3.0.0 → 3.0.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.
Files changed (3) hide show
  1. package/dist/index.js +17 -5
  2. package/index.ts +76 -7
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1847,19 +1847,31 @@ class CentraliSDK {
1847
1847
  * @param queryParams - Query parameters including filter, sort, pagination, and expand
1848
1848
  *
1849
1849
  * @example
1850
- * // Basic query with filter and sort
1850
+ * // Simple equality filter
1851
+ * const activeProducts = await centrali.queryRecords('Product', {
1852
+ * filter: { status: 'active' },
1853
+ * sort: '-createdAt',
1854
+ * limit: 10
1855
+ * });
1856
+ *
1857
+ * // Filter with operators
1851
1858
  * const products = await centrali.queryRecords('Product', {
1852
- * filter: 'inStock = true AND price < 100',
1859
+ * filter: { inStock: true, price: { lte: 100 } },
1853
1860
  * sort: '-createdAt',
1854
1861
  * limit: 10
1855
1862
  * });
1856
1863
  *
1857
- * // Query with expanded references
1864
+ * // Multiple values with 'in' operator
1858
1865
  * const orders = await centrali.queryRecords('Order', {
1859
- * filter: 'status = "pending"',
1866
+ * filter: { status: { in: ['pending', 'processing'] } },
1860
1867
  * expand: 'customer,items'
1861
1868
  * });
1862
1869
  * // Access expanded data: orders.data[0].data._expanded.customer
1870
+ *
1871
+ * // Range filters
1872
+ * const customers = await centrali.queryRecords('Customer', {
1873
+ * filter: { age: { gte: 18, lte: 65 }, verified: true }
1874
+ * });
1863
1875
  */
1864
1876
  queryRecords(recordSlug, queryParams) {
1865
1877
  const path = getRecordApiPath(this.options.workspaceId, recordSlug);
@@ -2170,7 +2182,7 @@ exports.CentraliSDK = CentraliSDK;
2170
2182
  *
2171
2183
  * // Subscribe to realtime events (Initial Sync Pattern):
2172
2184
  * // 1. First fetch initial data
2173
- * const orders = await client.queryRecords('Order', { filter: 'status = "pending"' });
2185
+ * const orders = await client.queryRecords('Order', { filter: { status: 'pending' } });
2174
2186
  * setOrders(orders.data);
2175
2187
  *
2176
2188
  * // 2. Then subscribe to realtime updates
package/index.ts CHANGED
@@ -566,12 +566,69 @@ export interface ExpandOptions {
566
566
  */
567
567
  export interface GetRecordOptions extends ExpandOptions {}
568
568
 
569
+ /**
570
+ * Filter operators for querying records.
571
+ * Use these within filter objects to apply comparison operations.
572
+ *
573
+ * @example
574
+ * // Filter with operators
575
+ * { age: { gte: 18, lte: 65 } }
576
+ * { status: { in: ['active', 'pending'] } }
577
+ * { email: { contains: '@gmail.com' } }
578
+ */
579
+ export interface FilterOperators {
580
+ /** Equal to (default if just a value is provided) */
581
+ eq?: string | number | boolean;
582
+ /** Not equal to */
583
+ ne?: string | number | boolean;
584
+ /** Greater than */
585
+ gt?: number | string;
586
+ /** Greater than or equal to */
587
+ gte?: number | string;
588
+ /** Less than */
589
+ lt?: number | string;
590
+ /** Less than or equal to */
591
+ lte?: number | string;
592
+ /** Value is in the provided array */
593
+ in?: (string | number)[];
594
+ /** Value is not in the provided array */
595
+ nin?: (string | number)[];
596
+ /** String contains substring (case-insensitive) */
597
+ contains?: string;
598
+ /** String starts with (case-insensitive) */
599
+ startswith?: string;
600
+ /** String ends with (case-insensitive) */
601
+ endswith?: string;
602
+ /** Array field contains any of the provided values */
603
+ hasAny?: (string | number)[];
604
+ /** Array field contains all of the provided values */
605
+ hasAll?: (string | number)[];
606
+ }
607
+
608
+ /**
609
+ * Filter value can be a direct value or an object with operators.
610
+ */
611
+ export type FilterValue = string | number | boolean | null | FilterOperators;
612
+
569
613
  /**
570
614
  * Options for querying records.
571
615
  */
572
616
  export interface QueryRecordOptions extends ExpandOptions {
573
- /** CFL filter expression (e.g., 'status = "active" AND price > 100') */
574
- filter?: string;
617
+ /**
618
+ * Filter object for querying records.
619
+ * Keys are field names, values are either direct values (for equality) or operator objects.
620
+ *
621
+ * @example
622
+ * // Simple equality filter
623
+ * { filter: { status: 'active' } }
624
+ *
625
+ * // Filter with operators
626
+ * { filter: { age: { gte: 18 }, status: { in: ['active', 'pending'] } } }
627
+ *
628
+ * // Multiple conditions (AND)
629
+ * { filter: { status: 'active', inStock: true, price: { lte: 100 } } }
630
+ */
631
+ filter?: Record<string, FilterValue>;
575
632
  /** Sort field with optional direction prefix (e.g., '-createdAt' for descending) */
576
633
  sort?: string;
577
634
  /** Maximum number of records to return */
@@ -3561,19 +3618,31 @@ export class CentraliSDK {
3561
3618
  * @param queryParams - Query parameters including filter, sort, pagination, and expand
3562
3619
  *
3563
3620
  * @example
3564
- * // Basic query with filter and sort
3621
+ * // Simple equality filter
3622
+ * const activeProducts = await centrali.queryRecords('Product', {
3623
+ * filter: { status: 'active' },
3624
+ * sort: '-createdAt',
3625
+ * limit: 10
3626
+ * });
3627
+ *
3628
+ * // Filter with operators
3565
3629
  * const products = await centrali.queryRecords('Product', {
3566
- * filter: 'inStock = true AND price < 100',
3630
+ * filter: { inStock: true, price: { lte: 100 } },
3567
3631
  * sort: '-createdAt',
3568
3632
  * limit: 10
3569
3633
  * });
3570
3634
  *
3571
- * // Query with expanded references
3635
+ * // Multiple values with 'in' operator
3572
3636
  * const orders = await centrali.queryRecords('Order', {
3573
- * filter: 'status = "pending"',
3637
+ * filter: { status: { in: ['pending', 'processing'] } },
3574
3638
  * expand: 'customer,items'
3575
3639
  * });
3576
3640
  * // Access expanded data: orders.data[0].data._expanded.customer
3641
+ *
3642
+ * // Range filters
3643
+ * const customers = await centrali.queryRecords('Customer', {
3644
+ * filter: { age: { gte: 18, lte: 65 }, verified: true }
3645
+ * });
3577
3646
  */
3578
3647
  public queryRecords<T = any>(
3579
3648
  recordSlug: string,
@@ -3951,7 +4020,7 @@ export class CentraliSDK {
3951
4020
  *
3952
4021
  * // Subscribe to realtime events (Initial Sync Pattern):
3953
4022
  * // 1. First fetch initial data
3954
- * const orders = await client.queryRecords('Order', { filter: 'status = "pending"' });
4023
+ * const orders = await client.queryRecords('Order', { filter: { status: 'pending' } });
3955
4024
  * setOrders(orders.data);
3956
4025
  *
3957
4026
  * // 2. Then subscribe to realtime updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Centrali Node SDK",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",