@protobase/cli 0.25.0 → 0.25.2

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/db/keys.js CHANGED
@@ -10,6 +10,15 @@ const isUniqueSet = (table, columns) => table.indexes.some((index) => {
10
10
  const indexed = plainColumns(index.columns);
11
11
  return index.unique && !index.partial && indexed && indexed.every((column) => columns.includes(column));
12
12
  });
13
- const leadingIndex = (table, column, tenantColumn) => table.indexes.find((index) => !index.partial && (index.columns[0] === column || tenantColumn !== void 0 && index.columns[0] === tenantColumn && index.columns[1] === column));
13
+ const coverageIndexes = (table) => table.indexes.map((index) => ({
14
+ name: index.name,
15
+ method: index.method,
16
+ partial: index.partial,
17
+ keys: index.columns.map((column, position) => ({
18
+ column,
19
+ definition: "",
20
+ opclass: index.opclasses[position] ?? ""
21
+ }))
22
+ }));
14
23
  //#endregion
15
- export { isUniqueSet, keyColumns, leadingIndex };
24
+ export { coverageIndexes, isUniqueSet, keyColumns };
@@ -1,17 +1,21 @@
1
- import { leadingIndex } from "../db/keys.js";
1
+ import { coverageIndexes } from "../db/keys.js";
2
2
  import { checkEnumValues } from "./check-values.js";
3
3
  import { columnDefault } from "./defaults.js";
4
4
  import { inferKind } from "./type-map.js";
5
5
  import { defaultColumn } from "./default-column.js";
6
6
  import { snakeName } from "./names.js";
7
7
  import { isTenantColumn } from "./tenant.js";
8
+ import { indexServes } from "@protobase/query";
8
9
  //#region src/infer/proposal.ts
9
- const columnIndexing = (table, column) => {
10
+ const columnIndexing = (table, column, type) => {
10
11
  const tenant = table.columns.find((c) => isTenantColumn(c.name))?.name;
11
- const index = leadingIndex(table, column, tenant);
12
+ const pinned = new Set(tenant ? [tenant] : []);
13
+ const indexes = coverageIndexes(table);
14
+ const sortable = indexes.some((index) => indexServes(index, column, "btree", pinned));
15
+ const trigram = type === "text" && indexes.some((index) => indexServes(index, column, "trigram", pinned));
12
16
  return {
13
- filterable: Boolean(index),
14
- sortable: index?.method === "btree"
17
+ filterable: sortable || trigram,
18
+ sortable
15
19
  };
16
20
  };
17
21
  const relationOf = (table, column, context) => {
@@ -60,7 +64,7 @@ const proposeField = (table, column, context) => {
60
64
  ...kind.type === "json" ? {
61
65
  filterable: false,
62
66
  sortable: false
63
- } : columnIndexing(table, column.name)
67
+ } : columnIndexing(table, column.name, kind.type)
64
68
  };
65
69
  };
66
70
  const needsColumnCall = (proposal) => defaultColumn(proposal.name) !== proposal.column;
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.25.0";
2
+ var version = "0.25.2";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -35,11 +35,11 @@
35
35
  "dependencies": {
36
36
  "@hono/node-server": "^2.1.3",
37
37
  "@hono/vite-dev-server": "^0.26.1",
38
- "@protobase/layout": "0.25.0",
39
- "@protobase/query": "0.25.0",
40
- "@protobase/schema": "0.25.0",
41
- "@protobase/server": "0.25.0",
42
- "@protobase/ui": "0.25.0",
38
+ "@protobase/layout": "0.25.2",
39
+ "@protobase/query": "0.25.2",
40
+ "@protobase/schema": "0.25.2",
41
+ "@protobase/server": "0.25.2",
42
+ "@protobase/ui": "0.25.2",
43
43
  "@react-email/render": "^2.1.0",
44
44
  "@scalar/hono-api-reference": "^0.12.10",
45
45
  "@tailwindcss/vite": "^4.3.3",