@rebasepro/types 0.29.0-canary.g0e3a0e7 → 0.29.0
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/dist/controllers/aggregates.d.ts +26 -0
- package/dist/controllers/data.d.ts +76 -11
- package/dist/controllers/data_driver.d.ts +34 -9
- package/dist/controllers/index.d.ts +1 -0
- package/dist/index.es.js +87 -3
- package/dist/index.es.js.map +1 -1
- package/dist/types/collections.d.ts +43 -0
- package/dist/types/filter-operators.d.ts +4 -2
- package/package.json +1 -1
|
@@ -187,6 +187,27 @@ export interface BaseCollectionConfig<M extends Record<string, unknown> = Record
|
|
|
187
187
|
*/
|
|
188
188
|
strictWrites?: boolean;
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* The SQL view a collection serves. See {@link PostgresCollectionConfig.view}.
|
|
192
|
+
*
|
|
193
|
+
* @group Models
|
|
194
|
+
*/
|
|
195
|
+
export interface CollectionView {
|
|
196
|
+
/** The view's `SELECT`, as SQL. Its columns are the collection's properties. */
|
|
197
|
+
query: string;
|
|
198
|
+
/**
|
|
199
|
+
* Store the rows (`CREATE MATERIALIZED VIEW`) rather than run the query on
|
|
200
|
+
* every read. Refresh them with the collection's `refresh()`.
|
|
201
|
+
*/
|
|
202
|
+
materialized?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Who may read a materialized view: callers holding one of these roles.
|
|
205
|
+
* Defaults to `["admin"]`, which `dataAsAdmin` and the server's own work
|
|
206
|
+
* hold. Ignored for a plain view, whose rows the base tables' policies
|
|
207
|
+
* decide.
|
|
208
|
+
*/
|
|
209
|
+
roles?: string[];
|
|
210
|
+
}
|
|
190
211
|
/**
|
|
191
212
|
* A collection backed by PostgreSQL (or any SQL database).
|
|
192
213
|
* Adds support for SQL-style relations (JOINs) and Row Level Security.
|
|
@@ -228,6 +249,28 @@ export interface PostgresCollectionConfig<M extends Record<string, unknown> = Re
|
|
|
228
249
|
* If not specified, "public" is used (or the default search path).
|
|
229
250
|
*/
|
|
230
251
|
schema?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Serve a SQL view instead of a table: the collection is read-only, and
|
|
254
|
+
* `db push` (and a managed boot) creates the view under `table` from
|
|
255
|
+
* `query`, recreating it when the query changes.
|
|
256
|
+
*
|
|
257
|
+
* The properties describe the view's columns, and one of them must be
|
|
258
|
+
* `isId`: a view has no primary key of its own.
|
|
259
|
+
*
|
|
260
|
+
* A plain view runs as the caller (`security_invoker`), so the policies of
|
|
261
|
+
* the tables it reads decide which rows each caller sees; `securityRules`
|
|
262
|
+
* do not apply to it. A materialized view stores its rows and has no
|
|
263
|
+
* row-level security at all, so it is served whole, and only to callers
|
|
264
|
+
* holding one of `roles`.
|
|
265
|
+
*
|
|
266
|
+
* ```ts
|
|
267
|
+
* view: {
|
|
268
|
+
* query: "SELECT lower(artist) AS artist, count(*)::int AS songs FROM songs GROUP BY 1",
|
|
269
|
+
* materialized: true
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
view?: CollectionView;
|
|
231
274
|
/**
|
|
232
275
|
* For SQL databases, you can define the relations between collections here.
|
|
233
276
|
* Relations describe JOINs, foreign keys, and junction tables.
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* │ "not-in" │ "nin" │ Value not in list │
|
|
22
22
|
* │ "array-contains" │ "cs" │ Array contains element │
|
|
23
23
|
* │ "array-contains-any" │ "csa" │ Array contains any of │
|
|
24
|
+
* │ "array-contains-all" │ "csall" │ Array contains all of │
|
|
25
|
+
* │ "array-contained-by" │ "cd" │ Array holds only elements of │
|
|
24
26
|
* │ "like" │ "like" │ SQL LIKE (case-sensitive) │
|
|
25
27
|
* │ "ilike" │ "ilike" │ SQL ILIKE (case-insensitive) │
|
|
26
28
|
* │ "not-like" │ "nlike" │ NOT LIKE (case-sensitive) │
|
|
@@ -195,7 +197,7 @@ export declare function sortKeyToString(key: SortKey): string;
|
|
|
195
197
|
*
|
|
196
198
|
* @group Models
|
|
197
199
|
*/
|
|
198
|
-
export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any" | "like" | "ilike" | "not-like" | "not-ilike" | "is-null" | "is-not-null";
|
|
200
|
+
export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any" | "array-contains-all" | "array-contained-by" | "like" | "ilike" | "not-like" | "not-ilike" | "is-null" | "is-not-null";
|
|
199
201
|
/**
|
|
200
202
|
* Used to define filters applied in collections.
|
|
201
203
|
*
|
|
@@ -317,7 +319,7 @@ export interface FilterPreset<Key extends string = string> {
|
|
|
317
319
|
* in application code. Used by `serializeFilter`/`deserializeFilter`
|
|
318
320
|
* in `@rebasepro/common`.
|
|
319
321
|
*/
|
|
320
|
-
export type RestFilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "cs" | "csa" | "like" | "ilike" | "nlike" | "nilike" | "isnull" | "notnull";
|
|
322
|
+
export type RestFilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "cs" | "csa" | "csall" | "cd" | "like" | "ilike" | "nlike" | "nilike" | "isnull" | "notnull";
|
|
321
323
|
/** Maps canonical operators to their REST short-code equivalents. */
|
|
322
324
|
export declare const CANONICAL_TO_REST: Readonly<Record<WhereFilterOp, RestFilterOp>>;
|
|
323
325
|
/** Maps REST short-code operators to their canonical equivalents. */
|