tsense 0.0.15 → 0.0.17

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/README.md CHANGED
@@ -89,20 +89,20 @@ type("string").configure({
89
89
 
90
90
  ### Collection Methods
91
91
 
92
- | Method/Property | Description |
93
- | --------------- | ----------- |
94
- | `create()` | Creates the collection in Typesense |
95
- | `drop()` | Deletes the collection |
96
- | `get(id)` | Retrieves a document by ID |
97
- | `delete(id)` | Deletes a document by ID |
98
- | `deleteMany(filter)` | Deletes documents matching filter |
99
- | `update(id, data)` | Updates a document by ID |
100
- | `updateMany(filter, data)` | Updates documents matching filter |
101
- | `upsert(docs)` | Inserts or updates documents |
102
- | `search(options)` | Searches the collection |
103
- | `syncSchema()` | Syncs schema (creates/patches collection) |
104
- | `syncData(options)` | Syncs data from external source |
105
- | `fields` | Array of generated field schemas |
92
+ | Method/Property | Description |
93
+ | -------------------------- | ----------------------------------------- |
94
+ | `create()` | Creates the collection in Typesense |
95
+ | `drop()` | Deletes the collection |
96
+ | `get(id)` | Retrieves a document by ID |
97
+ | `delete(id)` | Deletes a document by ID |
98
+ | `deleteMany(filter)` | Deletes documents matching filter |
99
+ | `update(id, data)` | Updates a document by ID |
100
+ | `updateMany(filter, data)` | Updates documents matching filter |
101
+ | `upsert(docs)` | Inserts or updates documents |
102
+ | `search(options)` | Searches the collection |
103
+ | `syncSchema()` | Syncs schema (creates/patches collection) |
104
+ | `syncData(options)` | Syncs data from external source |
105
+ | `fields` | Array of generated field schemas |
106
106
 
107
107
  ### Schema Sync
108
108
 
@@ -130,7 +130,11 @@ const Collection = new TSense({
130
130
  // ...
131
131
  dataSync: {
132
132
  getAllIds: async () => {
133
- return db.selectFrom("users").select("id").execute().then(rows => rows.map(r => r.id));
133
+ return db
134
+ .selectFrom("users")
135
+ .select("id")
136
+ .execute()
137
+ .then((rows) => rows.map((r) => r.id));
134
138
  },
135
139
  getItems: async (ids) => {
136
140
  return db.selectFrom("users").where("id", "in", ids).execute();
@@ -161,4 +165,4 @@ filter: { age: [25, 30, 35] } // IN
161
165
  filter: { age: { min: 20, max: 40 } } // Range
162
166
  filter: { name: { not: "John" } } // Not equal
163
167
  filter: { OR: [{ age: 25 }, { age: 30 }] } // OR conditions
164
- ```
168
+ ```
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { DateTransformer } from "./transformers/date.js";
3
3
  export { defaultTransformers } from "./transformers/defaults.js";
4
4
  export type { FieldTransformer } from "./transformers/types.js";
5
5
  export { TSense } from "./tsense.js";
6
- export type { ConnectionConfig, DeleteResult, FilterFor, HighlightOptions, SearchListOptions, SearchListResult, SearchOptions, SearchResult, SyncConfig, SyncOptions, SyncResult, TsenseOptions, UpdateResult, UpsertResult, } from "./types.js";
6
+ export type { ConnectionConfig, DeleteResult, FilterFor, HighlightOptions, ProjectSearch, SearchListOptions, SearchListResult, SearchOptions, SearchOptionsPlain, SearchOptionsWithOmit, SearchOptionsWithPick, SearchResult, SyncConfig, SyncOptions, SyncResult, TsenseOptions, UpdateResult, UpsertResult, } from "./types.js";
package/dist/tsense.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Type } from "arktype";
2
2
  import redaxios from "redaxios";
3
- import type { DeleteResult, FieldSchema, FilterFor, SearchListOptions, SearchListResult, SearchOptions, SearchResult, SyncOptions, SyncResult, TsenseOptions, UpdateResult, UpsertResult } from "./types.js";
3
+ import type { DeleteResult, FieldSchema, FilterFor, ProjectSearch, SearchListOptions, SearchListResult, SearchOptions, SearchOptionsPlain, SearchResult, SyncOptions, SyncResult, TsenseOptions, UpdateResult, UpsertResult } from "./types.js";
4
4
  declare const redaxiosInstance: {
5
5
  <T>(urlOrConfig: string | redaxios.Options, config?: redaxios.Options | undefined, _method?: any, data?: any, _undefined?: undefined): Promise<redaxios.Response<T>>;
6
6
  request: (<T_1 = any>(config?: redaxios.Options | undefined) => Promise<redaxios.Response<T_1>>) | (<T_2 = any>(url: string, config?: redaxios.Options | undefined) => Promise<redaxios.Response<T_2>>);
@@ -85,12 +85,12 @@ export declare class TSense<T extends Type> {
85
85
  deleteMany(filter: FilterFor<T["infer"]>): Promise<DeleteResult>;
86
86
  update(id: string, data: Partial<T["infer"]>): Promise<T["infer"]>;
87
87
  updateMany(filter: FilterFor<T["infer"]>, data: Partial<T["infer"]>): Promise<UpdateResult>;
88
- search(options: SearchOptions<T["infer"]>): Promise<SearchResult<T["infer"]>>;
88
+ search<const O extends SearchOptions<T["infer"]> = SearchOptionsPlain<T["infer"]>>(options: O): Promise<SearchResult<ProjectSearch<T["infer"], O>>>;
89
89
  searchList(options: SearchListOptions<T["infer"]>): Promise<SearchListResult<T["infer"]>>;
90
90
  count(filter?: FilterFor<T["infer"]>): Promise<number>;
91
91
  upsert(docs: T["infer"] | T["infer"][]): Promise<UpsertResult[]>;
92
92
  syncData(options?: SyncOptions): Promise<SyncResult>;
93
93
  private purgeOrphans;
94
- private exportIds;
94
+ exportIds(): Promise<string[]>;
95
95
  }
96
96
  export {};
package/dist/types.d.ts CHANGED
@@ -63,7 +63,7 @@ export type HighlightOptions<T> = {
63
63
  endTag?: string;
64
64
  };
65
65
  type SortableField<T> = Extract<keyof T, string> | "score";
66
- type BaseSearchOptions<T> = {
66
+ export type BaseSearchOptions<T> = {
67
67
  query?: string;
68
68
  queryBy?: (keyof T)[];
69
69
  filter?: FilterFor<T>;
@@ -73,16 +73,24 @@ type BaseSearchOptions<T> = {
73
73
  limit?: number;
74
74
  highlight?: boolean | HighlightOptions<T>;
75
75
  };
76
- export type SearchOptions<T> = BaseSearchOptions<T> & ({
77
- pick?: (keyof T)[];
76
+ export type SearchOptionsWithPick<T, K extends readonly (keyof T)[]> = BaseSearchOptions<T> & {
77
+ pick: K;
78
78
  omit?: never;
79
- } | {
80
- omit?: (keyof T)[];
79
+ };
80
+ export type SearchOptionsWithOmit<T, K extends readonly (keyof T)[]> = BaseSearchOptions<T> & {
81
+ omit: K;
81
82
  pick?: never;
82
- } | {
83
+ };
84
+ export type SearchOptionsPlain<T> = BaseSearchOptions<T> & {
83
85
  pick?: never;
84
86
  omit?: never;
85
- });
87
+ };
88
+ export type SearchOptions<T> = SearchOptionsWithPick<T, readonly (keyof T)[]> | SearchOptionsWithOmit<T, readonly (keyof T)[]> | SearchOptionsPlain<T>;
89
+ export type ProjectSearch<T, O> = O extends {
90
+ pick: readonly (infer K)[];
91
+ } ? Pick<T, Extract<K, keyof T>> : O extends {
92
+ omit: readonly (infer K)[];
93
+ } ? Omit<T, Extract<K, keyof T>> : T;
86
94
  export type SearchResult<T> = {
87
95
  count: number;
88
96
  data: T[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsense",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "private": false,
5
5
  "description": "Opinionated, fully typed typesense client",
6
6
  "keywords": [
@@ -28,7 +28,7 @@
28
28
  "build": "tsc",
29
29
  "ci": "bun run build && bun run format && bun run check-exports",
30
30
  "test": "bun test",
31
- "format": "biome check --write",
31
+ "format": "oxfmt check --write src tests",
32
32
  "check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
33
33
  "local-release": "changeset version && changeset publish",
34
34
  "prepublishOnly": "bun run ci"
@@ -49,4 +49,4 @@
49
49
  "arktype": "^2.1.29",
50
50
  "typescript": "^5"
51
51
  }
52
- }
52
+ }