@voltro/plugin-search 0.1.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/rpc.js ADDED
@@ -0,0 +1,56 @@
1
+ import { Schema as e } from "effect";
2
+ import { defineAction as t } from "@voltro/protocol";
3
+ //#region src/rpc.ts
4
+ var n = e.Union(e.String, e.Number, e.Boolean), r = e.Struct({
5
+ field: e.String,
6
+ op: e.Literal("eq", "neq", "gt", "gte", "lt", "lte", "in", "nin"),
7
+ value: e.Union(n, e.Array(n))
8
+ }), i = e.Struct({
9
+ fields: e.optional(e.Array(e.String)),
10
+ preTag: e.optional(e.String),
11
+ postTag: e.optional(e.String)
12
+ }), a = e.Struct({
13
+ doc: e.Record({
14
+ key: e.String,
15
+ value: e.Unknown
16
+ }),
17
+ highlights: e.optional(e.Record({
18
+ key: e.String,
19
+ value: e.String
20
+ }))
21
+ }), o = t({
22
+ name: "search.query",
23
+ input: e.Struct({
24
+ index: e.String,
25
+ q: e.String,
26
+ limit: e.optional(e.Number),
27
+ offset: e.optional(e.Number),
28
+ filters: e.optional(e.Array(r)),
29
+ facets: e.optional(e.Array(e.String)),
30
+ highlight: e.optional(i),
31
+ fuzziness: e.optional(e.Union(e.Number, e.Literal("auto"))),
32
+ engineParams: e.optional(e.Record({
33
+ key: e.String,
34
+ value: e.Unknown
35
+ }))
36
+ }),
37
+ output: e.Struct({
38
+ hits: e.Array(a),
39
+ facets: e.Record({
40
+ key: e.String,
41
+ value: e.Record({
42
+ key: e.String,
43
+ value: e.Number
44
+ })
45
+ })
46
+ })
47
+ }), s = [{
48
+ tag: "search.query",
49
+ kind: "action",
50
+ import: {
51
+ module: "@voltro/plugin-search/rpc",
52
+ name: "queryDescriptor"
53
+ }
54
+ }];
55
+ //#endregion
56
+ export { r as SearchFilterSchema, o as queryDescriptor, s as searchRpcClientImports };
package/dist/web.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ /** One clause on the wire — equality/negation/range/set membership. */
2
+ export declare interface SearchFilterInput {
3
+ readonly field: string;
4
+ readonly op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin';
5
+ readonly value: string | number | boolean | ReadonlyArray<string | number | boolean>;
6
+ }
7
+
8
+ export declare interface SearchHitOut<Doc> {
9
+ readonly doc: Doc;
10
+ readonly highlights?: Record<string, string>;
11
+ }
12
+
13
+ export declare interface SearchOptions {
14
+ readonly limit?: number;
15
+ readonly offset?: number;
16
+ /** Clauses ANDed together — equality, range, negation, set. */
17
+ readonly filters?: ReadonlyArray<SearchFilterInput>;
18
+ /** Facet-count fields (returned in `facets`). */
19
+ readonly facets?: ReadonlyArray<string>;
20
+ /** Matched-term highlighting (returned per-hit). */
21
+ readonly highlight?: {
22
+ readonly fields?: ReadonlyArray<string>;
23
+ readonly preTag?: string;
24
+ readonly postTag?: string;
25
+ };
26
+ /** Typo tolerance — a max edit distance (0 = exact) or `'auto'`. */
27
+ readonly fuzziness?: number | 'auto';
28
+ /** Escape hatch — forwarded verbatim to the underlying engine. */
29
+ readonly engineParams?: Record<string, unknown>;
30
+ }
31
+
32
+ export declare interface SearchResultOut<Doc> {
33
+ readonly hits: ReadonlyArray<SearchHitOut<Doc>>;
34
+ readonly facets: Record<string, Record<string, number>>;
35
+ }
36
+
37
+ export declare interface UseSearch<Doc> {
38
+ readonly run: (q: string, opts?: SearchOptions) => Promise<SearchResultOut<Doc>>;
39
+ /** Hit documents from the last run (unwrapped for the common list case). */
40
+ readonly results: ReadonlyArray<Doc>;
41
+ /** Facet counts from the last run. */
42
+ readonly facets: Record<string, Record<string, number>>;
43
+ readonly pending: boolean;
44
+ readonly error: unknown;
45
+ }
46
+
47
+ /** Imperative search hook bound to an index. Calls the `search.query` action;
48
+ * tenant scoping is applied server-side. Pass `opts` for paging, filters,
49
+ * facets, highlighting, fuzziness, and engine-param passthrough. */
50
+ export declare const useSearch: <Doc = Record<string, unknown>>(index: string, apiName?: string) => UseSearch<Doc>;
51
+
52
+ export { }
package/dist/web.js ADDED
@@ -0,0 +1,18 @@
1
+ import { useAction as e } from "@voltro/client";
2
+ //#region src/web.ts
3
+ var t = (t, n = "app") => {
4
+ let r = e(n, "search.query"), i = r.lastResult;
5
+ return {
6
+ run: (e, n) => r.run({
7
+ index: t,
8
+ q: e,
9
+ ...n ?? {}
10
+ }),
11
+ results: (i?.hits ?? []).map((e) => e.doc),
12
+ facets: i?.facets ?? {},
13
+ pending: r.pending,
14
+ error: r.error
15
+ };
16
+ };
17
+ //#endregion
18
+ export { t as useSearch };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@voltro/plugin-search",
3
+ "version": "0.1.0",
4
+ "description": "Keep an external search index (Typesense / Meilisearch / Algolia) in sync with framework tables via the post-commit ChangeEvent tap, then query it — tenant-scoped, with a backfill path and a useSearch() hook.",
5
+ "keywords": [
6
+ "voltro",
7
+ "typescript",
8
+ "framework"
9
+ ],
10
+ "license": "SEE LICENSE IN LICENSE",
11
+ "homepage": "https://voltro.dev",
12
+ "bugs": {
13
+ "email": "support@voltro.dev"
14
+ },
15
+ "author": {
16
+ "name": "Voltro UG",
17
+ "url": "https://voltro.dev"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./web": {
27
+ "types": "./dist/web.d.ts",
28
+ "import": "./dist/web.js",
29
+ "default": "./dist/web.js"
30
+ },
31
+ "./rpc": {
32
+ "types": "./dist/rpc.d.ts",
33
+ "import": "./dist/rpc.js",
34
+ "default": "./dist/rpc.js"
35
+ }
36
+ },
37
+ "main": "./dist/index.js",
38
+ "module": "./dist/index.js",
39
+ "types": "./dist/index.d.ts",
40
+ "sideEffects": false,
41
+ "engines": {
42
+ "node": ">=24.0.0"
43
+ },
44
+ "dependencies": {
45
+ "@voltro/client": "0.1.0",
46
+ "@voltro/database": "0.1.0",
47
+ "@voltro/protocol": "0.1.0"
48
+ },
49
+ "optionalDependencies": {
50
+ "algoliasearch": "^5.55.2",
51
+ "meilisearch": "^0.59.0",
52
+ "typesense": "^3.0.6"
53
+ },
54
+ "peerDependencies": {
55
+ "effect": "^3.21.4"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }