tsense 0.0.17 → 0.2.0-next.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/types.d.ts CHANGED
@@ -4,10 +4,12 @@ type BaseIfArray<T> = T extends (infer Q)[] ? Q : T;
4
4
  export type FieldSchema = {
5
5
  name: string;
6
6
  type: string;
7
+ sourceExpression?: string;
7
8
  facet?: boolean;
8
9
  sort?: boolean;
9
10
  index?: boolean;
10
11
  optional?: boolean;
12
+ enumValues?: string[];
11
13
  };
12
14
  export type SearchHit<T> = {
13
15
  document: T;
@@ -46,13 +48,29 @@ export type TsenseOptions<T extends Type> = {
46
48
  transformers?: FieldTransformer[];
47
49
  dataSync?: SyncConfig<T["infer"]>;
48
50
  };
51
+ export type StringFilter = {
52
+ not?: string;
53
+ notIn?: string[];
54
+ };
55
+ export type NumberFilter = {
56
+ not?: number;
57
+ notIn?: number[];
58
+ gt?: number;
59
+ gte?: number;
60
+ lt?: number;
61
+ lte?: number;
62
+ };
63
+ type DateFilter = {
64
+ not?: Date;
65
+ notIn?: Date[];
66
+ gt?: Date;
67
+ gte?: Date;
68
+ lt?: Date;
69
+ lte?: Date;
70
+ };
71
+ type FilterValueFor<T> = [T] extends [boolean] ? boolean : [T] extends [Date] ? Date | Date[] | DateFilter : [T] extends [number] ? number | number[] | NumberFilter : [T] extends [string] ? T | T[] | StringFilter : never;
49
72
  type SingleFilter<T> = Partial<{
50
- [K in keyof T]: BaseIfArray<T[K]> | NonNullable<BaseIfArray<T[K]>>[] | {
51
- not?: BaseIfArray<T[K]>;
52
- } | (NonNullable<T[K]> extends number | Date ? NonNullable<T[K]> extends infer Type ? {
53
- min?: Type;
54
- max?: Type;
55
- } : never : never);
73
+ [K in keyof T]: FilterValueFor<NonNullable<BaseIfArray<T[K]>>>;
56
74
  }>;
57
75
  export type FilterFor<T> = SingleFilter<T> & {
58
76
  OR?: FilterFor<T>[];
@@ -108,15 +126,17 @@ export type UpsertResult = {
108
126
  error?: string;
109
127
  document?: unknown;
110
128
  };
111
- type SearchListSort<T> = {
112
- field: keyof T;
113
- direction: "asc" | "desc";
129
+ export type SearchInput<T> = {
130
+ query?: string;
131
+ filter?: FilterFor<T>;
132
+ page?: number;
133
+ limit?: number;
114
134
  };
115
135
  export type SearchListOptions<T> = {
116
136
  query?: string;
117
137
  queryBy?: (keyof T)[];
118
138
  filter?: FilterFor<T>;
119
- sort: SearchListSort<T>;
139
+ sortBy: `${Extract<keyof T, string>}:${"asc" | "desc"}`;
120
140
  limit?: number;
121
141
  cursor?: string;
122
142
  };
@@ -125,6 +145,13 @@ export type SearchListResult<T> = {
125
145
  nextCursor: string | null;
126
146
  total: number;
127
147
  };
148
+ export type ScopedCollection<T> = {
149
+ search: <const O extends SearchOptions<T> = SearchOptionsPlain<T>>(options: O) => Promise<SearchResult<ProjectSearch<T, O>>>;
150
+ searchList: (options: SearchListOptions<T>) => Promise<SearchListResult<T>>;
151
+ count: (filter?: FilterFor<T>) => Promise<number>;
152
+ deleteMany: (filter: FilterFor<T>) => Promise<DeleteResult>;
153
+ updateMany: (filter: FilterFor<T>, data: Partial<T>) => Promise<UpdateResult>;
154
+ };
128
155
  export type SyncConfig<T> = {
129
156
  getAllIds: () => Promise<string[]>;
130
157
  getItems: (ids: string[]) => Promise<T[]>;
package/package.json CHANGED
@@ -1,52 +1,70 @@
1
1
  {
2
- "name": "tsense",
3
- "version": "0.0.17",
4
- "private": false,
5
- "description": "Opinionated, fully typed typesense client",
6
- "keywords": [
7
- "typesense"
8
- ],
9
- "homepage": "https://github.com/lobomfz/tsense",
10
- "license": "MIT",
11
- "files": [
12
- "dist"
13
- ],
14
- "type": "module",
15
- "sideEffects": false,
16
- "main": "dist/index.js",
17
- "types": "dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
22
- }
23
- },
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "scripts": {
28
- "build": "tsc",
29
- "ci": "bun run build && bun run format && bun run check-exports",
30
- "test": "bun test",
31
- "format": "oxfmt check --write src tests",
32
- "check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
33
- "local-release": "changeset version && changeset publish",
34
- "prepublishOnly": "bun run ci"
35
- },
36
- "dependencies": {
37
- "redaxios": "^0.5.1"
38
- },
39
- "devDependencies": {
40
- "@arethetypeswrong/cli": "^0.18.2",
41
- "@biomejs/biome": "2.1.4",
42
- "@changesets/cli": "^2.29.7",
43
- "@types/bun": "latest",
44
- "arktype": "^2.1.29",
45
- "oxfmt": "^0.28.0",
46
- "oxlint": "^1.43.0"
47
- },
48
- "peerDependencies": {
49
- "arktype": "^2.1.29",
50
- "typescript": "^5"
51
- }
52
- }
2
+ "name": "tsense",
3
+ "version": "0.2.0-next.0",
4
+ "private": false,
5
+ "description": "Opinionated, fully typed typesense client",
6
+ "keywords": [
7
+ "typesense"
8
+ ],
9
+ "homepage": "https://github.com/lobomfz/tsense",
10
+ "license": "MIT",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./filters": {
24
+ "types": "./dist/filters/index.d.ts",
25
+ "import": "./dist/filters/index.js"
26
+ },
27
+ "./react": {
28
+ "types": "./dist/react/index.d.ts",
29
+ "import": "./dist/react/index.js"
30
+ }
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "tsgo",
37
+ "check": "bun run scripts/check.ts",
38
+ "ci": "bun run build && bun run format && bun run check-exports",
39
+ "test": "bun test",
40
+ "format": "oxfmt check --write src tests",
41
+ "check-exports": "attw --pack . --ignore-rules cjs-resolves-to-esm no-resolution",
42
+ "local-release": "changeset version && changeset publish",
43
+ "prepublishOnly": "bun run ci"
44
+ },
45
+ "dependencies": {
46
+ "redaxios": "^0.5.1"
47
+ },
48
+ "devDependencies": {
49
+ "@arethetypeswrong/cli": "^0.18.2",
50
+ "@changesets/cli": "^2.30.0",
51
+ "@types/bun": "latest",
52
+ "@types/node": "^25.5.0",
53
+ "@types/react": "^19.2.14",
54
+ "@typescript/native-preview": "^7.0.0-dev.20260324.1",
55
+ "arktype": "^2.2.0",
56
+ "jscpd": "^4.0.8",
57
+ "oxfmt": "^0.42.0",
58
+ "oxlint": "^1.57.0",
59
+ "react": "^19.2.4"
60
+ },
61
+ "peerDependencies": {
62
+ "arktype": "^2.1.29",
63
+ "react": ">=18"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "react": {
67
+ "optional": true
68
+ }
69
+ }
70
+ }