@rebasepro/types 0.14.0 → 0.14.1-canary.g7e666eb

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.
@@ -1,7 +1,7 @@
1
1
  import type { VectorSearchParams } from "./data_driver";
2
2
  import type { ComputedSortField, SearchMatch } from "../types/search";
3
3
  import { Entity, EntityValues } from "../types/entities";
4
- import { WhereFilterOp, FieldPath, FilterValues, OrderByTuple } from "../types/filter-operators";
4
+ import { WhereFilterOp, FieldPath, FilterValues, OrderBySpec } from "../types/filter-operators";
5
5
  /**
6
6
  * Operator-blind filter value: whatever the column holds, a list of it, or null.
7
7
  *
@@ -145,10 +145,13 @@ export interface FindParams<M extends Record<string, unknown> = Record<string, u
145
145
  */
146
146
  logical?: LogicalCondition;
147
147
  /**
148
- * Sort order as a `[field, direction]` tuple.
148
+ * Sort order as a `[field, direction]` tuple, or a list of them applied in
149
+ * order of significance — the second key breaks ties on the first, and so on.
150
+ *
149
151
  * @example orderBy: ["created_at", "desc"]
152
+ * @example orderBy: [["roles", "asc"], ["created_at", "desc"]]
150
153
  */
151
- orderBy?: OrderByTuple<FieldPath<M> | ComputedSortField>;
154
+ orderBy?: OrderBySpec<FieldPath<M> | ComputedSortField>;
152
155
  /**
153
156
  * Relations to include in the response.
154
157
  *
@@ -1,6 +1,7 @@
1
1
  import { RebaseApiError } from "../errors";
2
2
  import type { EntityStatus, EntityValues } from "../types/entities";
3
3
  import type { CollectionConfig, FilterValues } from "../types/collections";
4
+ import type { OrderByTuple } from "../types/filter-operators";
4
5
  import type { RebaseCallContext } from "../call_context";
5
6
  import type { LogicalCondition } from "./data";
6
7
  /**
@@ -98,10 +99,25 @@ export interface FetchCollectionProps<M extends Record<string, unknown> = Record
98
99
  limit?: number;
99
100
  offset?: number;
100
101
  startAfter?: unknown;
101
- orderBy?: string;
102
+ /**
103
+ * The sort, in either of two spellings:
104
+ *
105
+ * - a field name, whose direction is the separate `order` below — the
106
+ * original single-column contract, which every existing driver reads;
107
+ * - a list of `[field, direction]` tuples applied in order of significance,
108
+ * which carries a multi-column sort and ignores `order` entirely.
109
+ *
110
+ * `normalizeDriverOrderBy` in `@rebasepro/common` collapses the pair to the
111
+ * list form. A driver that has not been taught the list form should read it
112
+ * through that helper rather than assume a string: handed an array, `String()`
113
+ * would produce a field name like `roles,asc` and the sort would 400 (or,
114
+ * with unknown-field warnings on, silently vanish).
115
+ */
116
+ orderBy?: string | OrderByTuple[];
102
117
  searchString?: string;
103
118
  /** Ask each row which declared search field matched — populates `_matches`. */
104
119
  searchExplain?: boolean;
120
+ /** Direction for the string form of `orderBy`. Ignored when `orderBy` is a list. */
105
121
  order?: "desc" | "asc";
106
122
  /** Vector similarity search configuration */
107
123
  vectorSearch?: VectorSearchParams;
@@ -393,7 +409,8 @@ export interface RestFetchService {
393
409
  filter?: FilterValues<string>;
394
410
  /** An `or(...)`/`and(...)` group, applied alongside `filter`. */
395
411
  logical?: LogicalCondition;
396
- orderBy?: string;
412
+ /** See `FetchCollectionProps.orderBy`: a field name plus `order`, or a list of tuples. */
413
+ orderBy?: string | OrderByTuple[];
397
414
  order?: "desc" | "asc";
398
415
  limit?: number;
399
416
  offset?: number;