@strav/search 0.1.0 → 0.1.1
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 +7 -7
- package/package.json +1 -1
- package/src/commands/search_flush.ts +2 -2
- package/src/commands/search_import.ts +2 -2
- package/src/drivers/algolia_driver.ts +1 -1
- package/src/drivers/meilisearch_driver.ts +1 -1
- package/src/drivers/typesense_driver.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/helpers.ts +1 -1
- package/src/search_manager.ts +1 -1
- package/src/search_provider.ts +2 -2
- package/src/searchable.ts +6 -6
- package/stubs/config/search.ts +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @strav/search
|
|
2
2
|
|
|
3
|
-
Full-text search for the [Strav](https://www.npmjs.com/package/@
|
|
3
|
+
Full-text search for the [Strav](https://www.npmjs.com/package/@strav/core) framework. Unified API for Meilisearch, Typesense, and Algolia with automatic indexing via model events.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add @
|
|
8
|
+
bun add @strav/search
|
|
9
9
|
bun strav install search
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Requires `@
|
|
12
|
+
Requires `@strav/core` as a peer dependency.
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import { SearchProvider } from '@
|
|
17
|
+
import { SearchProvider } from '@strav/search'
|
|
18
18
|
|
|
19
19
|
app.use(new SearchProvider())
|
|
20
20
|
```
|
|
@@ -22,7 +22,7 @@ app.use(new SearchProvider())
|
|
|
22
22
|
## Searchable Models
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import { searchable } from '@
|
|
25
|
+
import { searchable } from '@strav/search'
|
|
26
26
|
|
|
27
27
|
class Post extends searchable(BaseModel) {
|
|
28
28
|
static searchableAs = 'posts'
|
|
@@ -36,7 +36,7 @@ class Post extends searchable(BaseModel) {
|
|
|
36
36
|
## Usage
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import { search } from '@
|
|
39
|
+
import { search } from '@strav/search'
|
|
40
40
|
|
|
41
41
|
// Search
|
|
42
42
|
const results = await search.query('posts', 'hello world', {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command } from 'commander'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import { bootstrap, shutdown } from '@
|
|
4
|
-
import { BaseModel } from '@
|
|
3
|
+
import { bootstrap, shutdown } from '@strav/cli'
|
|
4
|
+
import { BaseModel } from '@strav/database'
|
|
5
5
|
import SearchManager from '../search_manager.ts'
|
|
6
6
|
|
|
7
7
|
export function register(program: Command): void {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command } from 'commander'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import { bootstrap, shutdown } from '@
|
|
4
|
-
import { BaseModel } from '@
|
|
3
|
+
import { bootstrap, shutdown } from '@strav/cli'
|
|
4
|
+
import { BaseModel } from '@strav/database'
|
|
5
5
|
import SearchManager from '../search_manager.ts'
|
|
6
6
|
|
|
7
7
|
export function register(program: Command): void {
|
package/src/errors.ts
CHANGED
package/src/helpers.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
* Search helper — the primary convenience API.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* import { search } from '@
|
|
15
|
+
* import { search } from '@strav/search'
|
|
16
16
|
*
|
|
17
17
|
* const results = await search.query('articles', 'typescript generics')
|
|
18
18
|
* await search.upsert('articles', 1, { title: 'Guide', body: '...' })
|
package/src/search_manager.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, Configuration, ConfigurationError } from '@
|
|
1
|
+
import { inject, Configuration, ConfigurationError } from '@strav/kernel'
|
|
2
2
|
import type { SearchEngine } from './search_engine.ts'
|
|
3
3
|
import type { SearchConfig, DriverConfig } from './types.ts'
|
|
4
4
|
import { MeilisearchDriver } from './drivers/meilisearch_driver.ts'
|
package/src/search_provider.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServiceProvider } from '@
|
|
2
|
-
import type { Application } from '@
|
|
1
|
+
import { ServiceProvider } from '@strav/kernel'
|
|
2
|
+
import type { Application } from '@strav/kernel'
|
|
3
3
|
import SearchManager from './search_manager.ts'
|
|
4
4
|
|
|
5
5
|
export default class SearchProvider extends ServiceProvider {
|
package/src/searchable.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BaseModel } from '@
|
|
2
|
-
import type { NormalizeConstructor } from '@
|
|
3
|
-
import { Emitter } from '@
|
|
1
|
+
import type { BaseModel } from '@strav/database'
|
|
2
|
+
import type { NormalizeConstructor } from '@strav/kernel'
|
|
3
|
+
import { Emitter } from '@strav/kernel'
|
|
4
4
|
import SearchManager from './search_manager.ts'
|
|
5
5
|
import type { SearchOptions, SearchResult, SearchDocument, IndexSettings } from './types.ts'
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ import type { SearchOptions, SearchResult, SearchDocument, IndexSettings } from
|
|
|
8
8
|
* Mixin that adds full-text search capabilities to a BaseModel subclass.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* import { BaseModel } from '@
|
|
12
|
-
* import { searchable } from '@
|
|
11
|
+
* import { BaseModel } from '@strav/database'
|
|
12
|
+
* import { searchable } from '@strav/search'
|
|
13
13
|
*
|
|
14
14
|
* class Article extends searchable(BaseModel) {
|
|
15
15
|
* declare id: number
|
|
@@ -24,7 +24,7 @@ import type { SearchOptions, SearchResult, SearchDocument, IndexSettings } from
|
|
|
24
24
|
* }
|
|
25
25
|
*
|
|
26
26
|
* // Composable with other mixins:
|
|
27
|
-
* import { compose } from '@
|
|
27
|
+
* import { compose } from '@strav/kernel'
|
|
28
28
|
* class Article extends compose(BaseModel, softDeletes, searchable) { }
|
|
29
29
|
*
|
|
30
30
|
* // Boot auto-indexing (in app bootstrap):
|
package/stubs/config/search.ts
CHANGED