@atscript/db-client 0.1.182 → 0.1.184

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/index.cjs CHANGED
@@ -195,7 +195,8 @@ var Client = class {
195
195
  * `GET /query` — query records with typed filter, sort, select, and relations.
196
196
  *
197
197
  * The response type narrows by the literal `$with` array in `query` —
198
- * relations not listed in `$with` are stripped from the row type.
198
+ * relations not listed in `$with` are stripped from the row type. A vector
199
+ * read (`controls: { $search, $vector }`) types `$score` on every row.
199
200
  */
200
201
  async query(query, opts) {
201
202
  return this._get("query", query, opts?.signal);
@@ -243,7 +244,7 @@ var Client = class {
243
244
  * `GET /pages` — paginated query with typed filter and relations.
244
245
  *
245
246
  * Response rows narrow by the literal `$with` array — same algebra as
246
- * {@link query}.
247
+ * {@link query}, `$score` on a vector read included.
247
248
  */
248
249
  async pages(query, page = 1, size = 10, opts) {
249
250
  return this._get("pages", {
package/dist/index.d.cts CHANGED
@@ -10,6 +10,18 @@ type Id<T> = IdOf<T>;
10
10
  type Response<T, Q> = ClientResponse<T, Q>;
11
11
  /** A read row: the response over the own fields plus the declared decorations `D`, each optional. */
12
12
  type DecoratedRow<T, Q, D> = Response<T, Q> & Partial<D>;
13
+ /**
14
+ * A `query()` / `pages()` row: {@link DecoratedRow}, plus `$score` on a vector read
15
+ * (`$search` with `$vector`, since 0.1.183): higher = closer, on the scale of `$threshold`.
16
+ */
17
+ type ReadRow<T, Q, D> = DecoratedRow<T, Q, D> & (Q extends {
18
+ controls: {
19
+ $search: string;
20
+ $vector: string;
21
+ };
22
+ } ? {
23
+ $score: number;
24
+ } : unknown);
13
25
  /**
14
26
  * One insert row for `returning`: an untyped client's row is any `object`,
15
27
  * which an array would match too — there it is any non-array object.
@@ -84,9 +96,10 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
84
96
  * `GET /query` — query records with typed filter, sort, select, and relations.
85
97
  *
86
98
  * The response type narrows by the literal `$with` array in `query` —
87
- * relations not listed in `$with` are stripped from the row type.
99
+ * relations not listed in `$with` are stripped from the row type. A vector
100
+ * read (`controls: { $search, $vector }`) types `$score` on every row.
88
101
  */
89
- query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D>[]>;
102
+ query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<ReadRow<T, Q, D>[]>;
90
103
  /**
91
104
  * `GET /query` with `$count: true` — returns record count.
92
105
  */
@@ -125,9 +138,9 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
125
138
  * `GET /pages` — paginated query with typed filter and relations.
126
139
  *
127
140
  * Response rows narrow by the literal `$with` array — same algebra as
128
- * {@link query}.
141
+ * {@link query}, `$score` on a vector read included.
129
142
  */
130
- pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D>>>;
143
+ pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<ReadRow<T, Q, D>>>;
131
144
  /**
132
145
  * `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
133
146
  *
package/dist/index.d.mts CHANGED
@@ -10,6 +10,18 @@ type Id<T> = IdOf<T>;
10
10
  type Response<T, Q> = ClientResponse<T, Q>;
11
11
  /** A read row: the response over the own fields plus the declared decorations `D`, each optional. */
12
12
  type DecoratedRow<T, Q, D> = Response<T, Q> & Partial<D>;
13
+ /**
14
+ * A `query()` / `pages()` row: {@link DecoratedRow}, plus `$score` on a vector read
15
+ * (`$search` with `$vector`, since 0.1.183): higher = closer, on the scale of `$threshold`.
16
+ */
17
+ type ReadRow<T, Q, D> = DecoratedRow<T, Q, D> & (Q extends {
18
+ controls: {
19
+ $search: string;
20
+ $vector: string;
21
+ };
22
+ } ? {
23
+ $score: number;
24
+ } : unknown);
13
25
  /**
14
26
  * One insert row for `returning`: an untyped client's row is any `object`,
15
27
  * which an array would match too — there it is any non-array object.
@@ -84,9 +96,10 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
84
96
  * `GET /query` — query records with typed filter, sort, select, and relations.
85
97
  *
86
98
  * The response type narrows by the literal `$with` array in `query` —
87
- * relations not listed in `$with` are stripped from the row type.
99
+ * relations not listed in `$with` are stripped from the row type. A vector
100
+ * read (`controls: { $search, $vector }`) types `$score` on every row.
88
101
  */
89
- query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<DecoratedRow<T, Q, D>[]>;
102
+ query<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, opts?: TClientCallOptions): Promise<ReadRow<T, Q, D>[]>;
90
103
  /**
91
104
  * `GET /query` with `$count: true` — returns record count.
92
105
  */
@@ -125,9 +138,9 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
125
138
  * `GET /pages` — paginated query with typed filter and relations.
126
139
  *
127
140
  * Response rows narrow by the literal `$with` array — same algebra as
128
- * {@link query}.
141
+ * {@link query}, `$score` on a vector read included.
129
142
  */
130
- pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<DecoratedRow<T, Q, D>>>;
143
+ pages<const Q extends DecoratedQuery<T, D> = DecoratedQuery<T, D>>(query?: Q, page?: number, size?: number, opts?: TClientCallOptions): Promise<PageResult<ReadRow<T, Q, D>>>;
131
144
  /**
132
145
  * `GET /geo` — distance-ranked geospatial search (tables with `@db.index.geo`).
133
146
  *
package/dist/index.mjs CHANGED
@@ -194,7 +194,8 @@ var Client = class {
194
194
  * `GET /query` — query records with typed filter, sort, select, and relations.
195
195
  *
196
196
  * The response type narrows by the literal `$with` array in `query` —
197
- * relations not listed in `$with` are stripped from the row type.
197
+ * relations not listed in `$with` are stripped from the row type. A vector
198
+ * read (`controls: { $search, $vector }`) types `$score` on every row.
198
199
  */
199
200
  async query(query, opts) {
200
201
  return this._get("query", query, opts?.signal);
@@ -242,7 +243,7 @@ var Client = class {
242
243
  * `GET /pages` — paginated query with typed filter and relations.
243
244
  *
244
245
  * Response rows narrow by the literal `$with` array — same algebra as
245
- * {@link query}.
246
+ * {@link query}, `$score` on a vector read included.
246
247
  */
247
248
  async pages(query, page = 1, size = 10, opts) {
248
249
  return this._get("pages", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-client",
3
- "version": "0.1.182",
3
+ "version": "0.1.184",
4
4
  "description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -50,11 +50,11 @@
50
50
  "@atscript/core": "^0.2.13",
51
51
  "@atscript/typescript": "^0.2.13",
52
52
  "unplugin-atscript": "^0.2.13",
53
- "@atscript/db": "0.1.182"
53
+ "@atscript/db": "0.1.184"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@atscript/typescript": "^0.2.13",
57
- "@atscript/db": "^0.1.182"
57
+ "@atscript/db": "^0.1.184"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "vp pack",