@rebasepro/server-postgres 0.11.1-canary.gf2b0ff7 → 0.11.1-canary.gfadf355

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
  /**
2
2
  * Build drizzle tables at runtime from an introspected schema.
3
3
  *
4
- * CMS mode gets its drizzle tables from a generated `schema.generated.ts` that
4
+ * A project with declared collections gets its drizzle tables from a generated `schema.generated.ts` that
5
5
  * the developer commits. BaaS mode has no such file — it points at a database
6
6
  * and serves it — so the equivalent table objects are constructed here from
7
7
  * `information_schema` metadata.
@@ -7,7 +7,7 @@
7
7
  * single config file.
8
8
  *
9
9
  * Distinct from `introspect-db.ts`, which runs the same queries but emits
10
- * TypeScript *source* for a developer to edit and commit (CMS mode). The two
10
+ * TypeScript *source* for a developer to edit and commit (declared collections). The two
11
11
  * share the mapping helpers in `introspect-db-logic.ts` so a table is described
12
12
  * the same way whether it was generated or introspected.
13
13
  */
@@ -20,6 +20,32 @@ export declare class FetchService {
20
20
  * Safely narrows the DrizzleClient union type to access db.query[tableName].
21
21
  */
22
22
  private getQueryBuilder;
23
+ /**
24
+ * The context the condition builder needs to compile a filter key that is
25
+ * not a column name outright.
26
+ *
27
+ * Two such keys. An owning relation's key resolves through the collection's
28
+ * relations to its foreign-key column; a relation whose link lives on the
29
+ * target table or in a junction resolves to a correlated `EXISTS`, which
30
+ * needs the registry to reach that other table and this table's key column
31
+ * to correlate back.
32
+ *
33
+ * Looked up rather than passed: every read path already has the path, only
34
+ * some have the collection, and a path that names no registered collection
35
+ * (a nested/derived one) is not an error here — the builder simply falls
36
+ * back to guessing the default key shapes, and a relation filter it cannot
37
+ * compile stays unresolvable and so fails closed.
38
+ */
39
+ private filterContext;
40
+ /**
41
+ * The table column this collection's rows are keyed by, or `undefined`.
42
+ *
43
+ * `getPrimaryKeys` rather than `requirePrimaryKeys`: a collection with no
44
+ * resolvable key is not an error on the filter path — it only means the
45
+ * relation filters that would correlate on it cannot be compiled, which
46
+ * the builder already handles by failing that field closed.
47
+ */
48
+ private resolveIdColumn;
23
49
  /**
24
50
  * Build filter conditions from FilterValues
25
51
  * Delegates to DrizzleConditionBuilder.buildFilterConditions
@@ -28,6 +54,15 @@ export declare class FetchService {
28
54
  /**
29
55
  * Resolves the correct Drizzle column for sorting.
30
56
  * Automatically maps owning relation property keys to their underlying foreign key column.
57
+ *
58
+ * The relation's own `localKey` is the authority for that foreign key, not
59
+ * `<field>_id`. The default local key comes from `generateForeignKeyName`,
60
+ * which snake-cases *and singularises* — `userProfile` → `user_profile_id`,
61
+ * `users` → `user_id` — and an author can override it outright. A wrong
62
+ * guess resolves to nothing, the caller drops the `ORDER BY`, and the rows
63
+ * come back in whatever order Postgres pleases: paging over that repeats
64
+ * and skips rows rather than erroring. The guesses stay, last, for a
65
+ * caller that hands over no collection to resolve against.
31
66
  */
32
67
  private resolveOrderByField;
33
68
  /**
@@ -35,7 +70,7 @@ export declare class FetchService {
35
70
  * Converts collection relations to a Drizzle-compatible `with` object.
36
71
  *
37
72
  * When `include` is provided, only those relations are loaded.
38
- * When `include` is absent, ALL relations are loaded (CMS path).
73
+ * When `include` is absent, ALL relations are loaded (the admin path).
39
74
  *
40
75
  * Automatically detects many-to-many junction tables and nests
41
76
  * the target relation so actual row data is returned.
@@ -10,7 +10,9 @@ import { PostgresCollectionRegistry } from "../collections/PostgresCollectionReg
10
10
  *
11
11
  * - `"ref"` — a `{ id, path, __type: "relation" }` reference carrying the
12
12
  * target's values. This is what the admin renders.
13
- * - `"inline"` — the target's own columns, flat. This is what REST serves.
13
+ * - `"inline"` — the target's own columns, flat. This is what REST serves, and
14
+ * — since the in-process SDK reads through the same pipeline — what
15
+ * `rebase.data` / `context.data` serve too. A developer never sees a ref.
14
16
  *
15
17
  * They used to be two functions that happened to agree, and the agreement was
16
18
  * not enforced by anything: the row-identity bug had to be fixed five times
@@ -261,6 +261,16 @@ function isChannelBusInstance(setting) {
261
261
  * @group Models
262
262
  */
263
263
  var DEFAULT_DATA_SOURCE_KEY = "(default)";
264
+ /**
265
+ * Relation kinds assumed filterable when a driver does not say.
266
+ *
267
+ * `belongsTo` alone: its filter is a comparison on a column of the row being
268
+ * filtered, the one shape that needs no query construction a driver might not
269
+ * have. Everything else is a correlated subquery over another table.
270
+ *
271
+ * @group Models
272
+ */
273
+ var DEFAULT_FILTERABLE_RELATION_KINDS = ["belongsTo"];
264
274
  /** @group Models */
265
275
  var POSTGRES_CAPABILITIES = {
266
276
  key: "postgres",
@@ -272,6 +282,12 @@ var POSTGRES_CAPABILITIES = {
272
282
  supportsColumnTypes: true,
273
283
  supportsRealtime: true,
274
284
  filterOperators: ALL_WHERE_FILTER_OPS,
285
+ filterableRelationKinds: [
286
+ "belongsTo",
287
+ "manyToMany",
288
+ "hasMany",
289
+ "hasOne"
290
+ ],
275
291
  supportsSQLAdmin: true,
276
292
  supportsDocumentAdmin: false,
277
293
  supportsSchemaAdmin: true
@@ -287,6 +303,7 @@ var FIREBASE_CAPABILITIES = {
287
303
  supportsColumnTypes: false,
288
304
  supportsRealtime: true,
289
305
  filterOperators: ALL_WHERE_FILTER_OPS.filter((op) => op !== "like" && op !== "ilike" && op !== "not-like" && op !== "not-ilike"),
306
+ filterableRelationKinds: [],
290
307
  supportsSQLAdmin: false,
291
308
  supportsDocumentAdmin: false,
292
309
  supportsSchemaAdmin: false
@@ -302,6 +319,7 @@ var MONGODB_CAPABILITIES = {
302
319
  supportsColumnTypes: false,
303
320
  supportsRealtime: false,
304
321
  filterOperators: ALL_WHERE_FILTER_OPS,
322
+ filterableRelationKinds: [],
305
323
  supportsSQLAdmin: false,
306
324
  supportsDocumentAdmin: true,
307
325
  supportsSchemaAdmin: true
@@ -321,6 +339,7 @@ var DEFAULT_CAPABILITIES = {
321
339
  supportsColumnTypes: true,
322
340
  supportsRealtime: true,
323
341
  filterOperators: ALL_WHERE_FILTER_OPS,
342
+ filterableRelationKinds: DEFAULT_FILTERABLE_RELATION_KINDS,
324
343
  supportsSQLAdmin: true,
325
344
  supportsDocumentAdmin: true,
326
345
  supportsSchemaAdmin: true
@@ -343,4 +362,4 @@ function getDataSourceCapabilities(engine) {
343
362
  //#endregion
344
363
  export { isSchemaAdmin as a, hasForeignKeyOnTarget as c, isPostgresCollectionConfig as d, NULL_OPS as f, Vector as g, EntityRelation as h, isSQLAdmin as i, isManyToMany as l, toCanonicalOp as m, getDataSourceCapabilities as n, ANONYMOUS_USER_ID as o, REST_TO_CANONICAL as p, isChannelBusInstance as r, policy as s, DEFAULT_DATA_SOURCE_KEY as t, getDeclaredSubcollections as u };
345
364
 
346
- //# sourceMappingURL=src-D5xBTl32.js.map
365
+ //# sourceMappingURL=src-C5hyt1Um.js.map