@etohq/search 0.0.0-stage → 2.0.5
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/LICENSE +21 -0
- package/NOTICE +24 -0
- package/README.md +188 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/joiner-config.d.ts +8 -0
- package/dist/joiner-config.d.ts.map +1 -0
- package/dist/joiner-config.js +12 -0
- package/dist/joiner-config.js.map +1 -0
- package/dist/loaders/providers.d.ts +5 -0
- package/dist/loaders/providers.d.ts.map +1 -0
- package/dist/loaders/providers.js +23 -0
- package/dist/loaders/providers.js.map +1 -0
- package/dist/migrations/Migration20260805085626.d.ts +6 -0
- package/dist/migrations/Migration20260805085626.d.ts.map +1 -0
- package/dist/migrations/Migration20260805085626.js +23 -0
- package/dist/migrations/Migration20260805085626.js.map +1 -0
- package/dist/migrations/Migration20260903085616.d.ts +6 -0
- package/dist/migrations/Migration20260903085616.d.ts.map +1 -0
- package/dist/migrations/Migration20260903085616.js +32 -0
- package/dist/migrations/Migration20260903085616.js.map +1 -0
- package/dist/migrations/Migration20260911115931.d.ts +6 -0
- package/dist/migrations/Migration20260911115931.d.ts.map +1 -0
- package/dist/migrations/Migration20260911115931.js +14 -0
- package/dist/migrations/Migration20260911115931.js.map +1 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +10 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/search-index-sync.d.ts +34 -0
- package/dist/models/search-index-sync.d.ts.map +1 -0
- package/dist/models/search-index-sync.js +47 -0
- package/dist/models/search-index-sync.js.map +1 -0
- package/dist/models/search-index-version.d.ts +34 -0
- package/dist/models/search-index-version.d.ts.map +1 -0
- package/dist/models/search-index-version.js +37 -0
- package/dist/models/search-index-version.js.map +1 -0
- package/dist/models/search-index.d.ts +28 -0
- package/dist/models/search-index.d.ts.map +1 -0
- package/dist/models/search-index.js +28 -0
- package/dist/models/search-index.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +11 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/search-module-service.d.ts +72 -0
- package/dist/services/search-module-service.d.ts.map +1 -0
- package/dist/services/search-module-service.js +336 -0
- package/dist/services/search-module-service.js.map +1 -0
- package/dist/services/search-provider.d.ts +23 -0
- package/dist/services/search-provider.d.ts.map +1 -0
- package/dist/services/search-provider.js +64 -0
- package/dist/services/search-provider.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +131 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/active-version-cache.d.ts +36 -0
- package/dist/utils/active-version-cache.d.ts.map +1 -0
- package/dist/utils/active-version-cache.js +73 -0
- package/dist/utils/active-version-cache.js.map +1 -0
- package/dist/utils/deletion.d.ts +11 -0
- package/dist/utils/deletion.d.ts.map +1 -0
- package/dist/utils/deletion.js +50 -0
- package/dist/utils/deletion.js.map +1 -0
- package/dist/utils/index.d.ts +88 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +524 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/ingestion.d.ts +12 -0
- package/dist/utils/ingestion.d.ts.map +1 -0
- package/dist/utils/ingestion.js +78 -0
- package/dist/utils/ingestion.js.map +1 -0
- package/dist/utils/migrations.d.ts +5 -0
- package/dist/utils/migrations.d.ts.map +1 -0
- package/dist/utils/migrations.js +143 -0
- package/dist/utils/migrations.js.map +1 -0
- package/dist/utils/rate-limit.d.ts +9 -0
- package/dist/utils/rate-limit.d.ts.map +1 -0
- package/dist/utils/rate-limit.js +47 -0
- package/dist/utils/rate-limit.js.map +1 -0
- package/dist/utils/seeding.d.ts +29 -0
- package/dist/utils/seeding.d.ts.map +1 -0
- package/dist/utils/seeding.js +639 -0
- package/dist/utils/seeding.js.map +1 -0
- package/dist/utils/versions.d.ts +50 -0
- package/dist/utils/versions.d.ts.map +1 -0
- package/dist/utils/versions.js +113 -0
- package/dist/utils/versions.js.map +1 -0
- package/package.json +56 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Etohq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This package contains code ported from Medusa (https://github.com/medusajs/medusa),
|
|
2
|
+
which is licensed under the MIT License:
|
|
3
|
+
|
|
4
|
+
The MIT License (MIT)
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2021 Medusajs
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,189 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @etohq/search
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Search Module for eto: manages search indexes, their versions and their sync
|
|
4
|
+
history, and serves full-text search with filtering, sorting and faceting
|
|
5
|
+
through pluggable search providers. Ported from Medusa's `@medusajs/search`
|
|
6
|
+
(MIT, see `NOTICE`) and kept close to it so later upstream changes port
|
|
7
|
+
cleanly.
|
|
8
|
+
|
|
9
|
+
| | |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Package | `@etohq/search` |
|
|
12
|
+
| Module key | `Modules.SEARCH` (`"search"`) |
|
|
13
|
+
| Default provider | [`@etohq/search-postgres`](../providers/search-postgres) — no vendor needed |
|
|
14
|
+
| Replaces | `@etohq/search-legacy` (`AbstractLegacySearchService`), kept for eto-community until it moves over |
|
|
15
|
+
|
|
16
|
+
## What it does
|
|
17
|
+
|
|
18
|
+
- Index definitions are declared with `defineSearchIndex` and the `search.define`
|
|
19
|
+
field DSL from `@etohq/framework/utils`: keyword, text, integer, float,
|
|
20
|
+
boolean, date, geo, object, vector; each field searchable, filterable,
|
|
21
|
+
sortable, facetable and/or retrievable. `graphSeed` / `graphConsume` build
|
|
22
|
+
`seed` / `consume` from `query.graph`.
|
|
23
|
+
- Each logical index has versioned physical indexes. `migrate:search` (or
|
|
24
|
+
`migrateSearchIndexes`) creates or rebuilds them when a definition drifts;
|
|
25
|
+
the worker seeds them at start, swaps the new version in and runs a catch-up
|
|
26
|
+
pass for writes that landed during the seed.
|
|
27
|
+
- Events named in a definition's `events` are ingested: the module subscribes
|
|
28
|
+
to them on the event bus (worker mode only) and applies what `consume`
|
|
29
|
+
returns.
|
|
30
|
+
- `query.search` searches and hydrates fields the index doesn't hold through
|
|
31
|
+
`query.graph`. Writes are serialized with the Locking Module when present,
|
|
32
|
+
and rate-limited providers are retried.
|
|
33
|
+
- More than one provider can be registered; an index picks one with
|
|
34
|
+
`provider`.
|
|
35
|
+
|
|
36
|
+
## Registering it
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Modules } from "@etohq/framework/utils"
|
|
40
|
+
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
modules: {
|
|
43
|
+
[Modules.SEARCH]: {
|
|
44
|
+
resolve: "@etohq/search",
|
|
45
|
+
options: {
|
|
46
|
+
providers: [{ resolve: "@etohq/search-postgres", id: "postgres" }],
|
|
47
|
+
// indexes: [...] — or load files with withLoader({ searchIndexPaths })
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then, at boot:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
withLoader({
|
|
58
|
+
// ...
|
|
59
|
+
searchIndexPaths: [join(__dirname, "search")], // defineSearchIndex files
|
|
60
|
+
searchSurfaces: [storeSearchConfig], // each checked against the module at boot
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Before the first boot, and after changing a definition, create the physical
|
|
65
|
+
indexes with `eto migrate:search` (or call `migrateSearchIndexes` from a deploy
|
|
66
|
+
step). Running workers fill them.
|
|
67
|
+
|
|
68
|
+
## Options
|
|
69
|
+
|
|
70
|
+
| Option | Description | Default |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `providers` | `{ resolve, id, options? }[]` providers to register. | — |
|
|
73
|
+
| `default_provider` | Provider for indexes that name none. Required with more than one. | the only one |
|
|
74
|
+
| `index_prefix` | Prefix for every physical index name, for shared engines. | — |
|
|
75
|
+
| `indexes` | Definitions passed inline (merged with those loaded from files). | — |
|
|
76
|
+
| `reindex.batch_size` | Documents written per request while seeding. | `100` |
|
|
77
|
+
|
|
78
|
+
## Scoping (eto deviations from Medusa)
|
|
79
|
+
|
|
80
|
+
Medusa's `/store/search` hardcodes `status` and `sales_channel_ids` on product
|
|
81
|
+
indexes and, when they are missing, only logs a warning and serves the index
|
|
82
|
+
unscoped. eto never fails open, and the scoping is domain-neutral so the same
|
|
83
|
+
rules serve a storefront and a Conz network (eto-community's sources):
|
|
84
|
+
|
|
85
|
+
| | Storefront | Conz network |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `visible` | `status = published` | `active = true` |
|
|
88
|
+
| `audiences` | the publishable key's sales channels | the member's readable chapters (`accessibleChapters`) |
|
|
89
|
+
| `root` | the root of the key's channel tree (`SalesChannel.mpath`) | the root source of the network (handle lineage) |
|
|
90
|
+
|
|
91
|
+
A document carries its audiences and the roots of their trees, derived in the
|
|
92
|
+
same pass (`treeRootsOf` from `@etohq/framework/utils` reads a root off any
|
|
93
|
+
dotted path: a channel `mpath`, a source handle). A request resolves its
|
|
94
|
+
audiences and its one root. The root is a hard tenant boundary: a channel or
|
|
95
|
+
chapter id from another tree that reaches a request matches nothing.
|
|
96
|
+
|
|
97
|
+
1. **Every index served outside the back office declares its scoping.** The
|
|
98
|
+
definition names the fields with `scope`, and `configureScopedSearch`
|
|
99
|
+
(Medusa's name: `configureStoreSearch`) gives each exposed index a `scope`
|
|
100
|
+
resolver returning the request's `audience_ids` and `root_id`. Every query
|
|
101
|
+
is ANDed with *visible*, *shares an audience* and *under the root*; array
|
|
102
|
+
fields match by overlap, scalar ones by membership. An exposed index without
|
|
103
|
+
a resolver is refused by `configureScopedSearch`; one whose definition has
|
|
104
|
+
no `scope` is refused at boot (`withLoader({ searchSurfaces })` or
|
|
105
|
+
`assertScopedSearchIndexes`) and again per request. A request resolving no
|
|
106
|
+
audiences or no root is refused.
|
|
107
|
+
2. **Scoping fields are filterable, never facetable.** `defineSearchIndex` and
|
|
108
|
+
the module refuse a definition whose `scope` field is facetable. This
|
|
109
|
+
closes Medusa's disjunctive facet-count leak, where faceting on a scoping
|
|
110
|
+
field drops its own filter and counts documents outside the scope.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import {
|
|
114
|
+
defineSearchIndex,
|
|
115
|
+
graphConsume,
|
|
116
|
+
graphSeed,
|
|
117
|
+
search,
|
|
118
|
+
} from "@etohq/framework/utils"
|
|
119
|
+
|
|
120
|
+
const fields = ["id", "title", "brand", "status", "channel_ids", "channel_root_ids"]
|
|
121
|
+
|
|
122
|
+
export default defineSearchIndex({
|
|
123
|
+
name: "products",
|
|
124
|
+
entity: "product",
|
|
125
|
+
fields: search.define({
|
|
126
|
+
id: search.keyword().filterable(),
|
|
127
|
+
title: search.text().searchable(),
|
|
128
|
+
brand: search.keyword().filterable().facetable(),
|
|
129
|
+
// scoping: filterable, never .facetable()
|
|
130
|
+
status: search.keyword().filterable(),
|
|
131
|
+
channel_ids: search.keyword().array().filterable(),
|
|
132
|
+
channel_root_ids: search.keyword().array().filterable(),
|
|
133
|
+
}),
|
|
134
|
+
scope: {
|
|
135
|
+
visible: { field: "status", value: "published" },
|
|
136
|
+
audiences: { field: "channel_ids" },
|
|
137
|
+
root: { field: "channel_root_ids" },
|
|
138
|
+
},
|
|
139
|
+
events: ["product.created", "product.updated", "product.deleted"],
|
|
140
|
+
seed: graphSeed({ fields }),
|
|
141
|
+
consume: graphConsume({ fields }),
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Routes an app exposes
|
|
146
|
+
|
|
147
|
+
eto ships no HTTP routes for search: Medusa's `/store/search` and
|
|
148
|
+
`/admin/search-indexes` routes are left out, and an app (Shopabox serves them
|
|
149
|
+
through Encore) exposes its own on top of these functions.
|
|
150
|
+
|
|
151
|
+
| Route | Calls | What it does |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
| `POST /store/search` (or a network's search) | `scopedSearch({ body, context, config, query, searchModule })` from `@etohq/framework/search` (`storeSearch` is the same function) | Storefront or network search. Body: one `StoreSearchQuery` or `{ queries: [...] }` (max 20, `take` ≤ 100), validated with `ScopedSearchValidator`. Only indexes in the surface's config are served; others answer 404 like a missing index. Applies the scope above plus the config's `filters`, refuses fields the index can't return, never hydrates through the graph, and answers `{ results: SearchResult[] }` in order — the contract `@etohq/instantsearch-adapter` speaks. A storefront needs the publishable key context (for channels). |
|
|
154
|
+
| `GET /admin/search-indexes` | `searchModule.listIndexes()` | Each index with its provider, status (`pending`/`building`/`ready`/`error`) and indexed fields. |
|
|
155
|
+
| `POST /admin/search-indexes/:name/reindex` (or `POST /admin/search-indexes/reindex` for all) | `reindexSearchIndexesWorkflow` from `@etohq/core-flows` | Rebuilds from `seed` in the background. Input: `index?`, `strategy?` (`swap` builds a new version and swaps it in; `in_place` writes into the active one), `filters?` (partial, always in place), `since?` (ISO date, only rows changed since). Returns at once; the `searchIndexesReindexed` hook fires when done. |
|
|
156
|
+
| `DELETE /admin/search-indexes/:name` | `deleteSearchIndexWorkflow` from `@etohq/core-flows` | Drops every version of the index, its documents and its records. A definition that still declares it builds it again on the next `migrate:search`. |
|
|
157
|
+
|
|
158
|
+
Admin routes need the app's admin authentication; the store route only the
|
|
159
|
+
publishable key.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// Encore endpoint (sketch)
|
|
163
|
+
const storeSearchConfig = configureScopedSearch<EtoStoreRequestContext>({
|
|
164
|
+
allowed_indexes: {
|
|
165
|
+
products: {
|
|
166
|
+
scope: (ctx) => ({
|
|
167
|
+
// eto-commerce: channelRequestScope(channels) → { audience_ids, root_id },
|
|
168
|
+
// refusing a key whose channels span several trees.
|
|
169
|
+
...channelScopeOf(ctx.publishableKeyContext.sales_channel_ids),
|
|
170
|
+
}),
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
export const search = api({ method: "POST", path: "/store/search" }, async (body) => {
|
|
176
|
+
const ctx = storeReqContext(currentRequest())
|
|
177
|
+
return await scopedSearch({
|
|
178
|
+
body,
|
|
179
|
+
context: ctx,
|
|
180
|
+
config: storeSearchConfig,
|
|
181
|
+
query: ctx.scope.resolve(ContainerRegistrationKeys.QUERY),
|
|
182
|
+
searchModule: ctx.scope.resolve(Modules.SEARCH),
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`StoreSearchQuery.filters` is recursive, which Encore's parser can't handle;
|
|
188
|
+
declare the endpoint's own wire type and hand the parsed body through —
|
|
189
|
+
`scopedSearch` validates it.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./types";
|
|
2
|
+
import { SearchModuleService } from "./services";
|
|
3
|
+
declare const _default: import("@etohq/types").ModuleExports<typeof SearchModuleService> & {
|
|
4
|
+
linkable: Record<string, any>;
|
|
5
|
+
sqlObjects: {
|
|
6
|
+
functions: import("@etohq/types").DmlFunction[];
|
|
7
|
+
triggers: import("@etohq/types").DmlTrigger[];
|
|
8
|
+
views: import("@etohq/types").DmlView[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;AAGhB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;;;;;;;;;AAG/C,wBAGE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
require("./types");
|
|
7
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
8
|
+
const _services_1 = require("./services");
|
|
9
|
+
const providers_1 = __importDefault(require("./loaders/providers"));
|
|
10
|
+
exports.default = (0, utils_1.Module)(utils_1.Modules.SEARCH, {
|
|
11
|
+
service: _services_1.SearchModuleService,
|
|
12
|
+
loaders: [providers_1.default],
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,mBAAgB;AAEhB,kDAAwD;AACxD,yCAA+C;AAC/C,oEAAiD;AAEjD,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,MAAM,EAAE;IACpC,OAAO,EAAE,+BAAmB;IAC5B,OAAO,EAAE,CAAC,mBAAe,CAAC;CAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nothing here is queryable or linkable — `SearchIndex` and `SearchIndexSync` are
|
|
3
|
+
* the module's own bookkeeping. `models: []` has to be explicit: otherwise
|
|
4
|
+
* `defineJoinerConfig` discovers `src/models` from disk and makes it all linkable,
|
|
5
|
+
* whether or not the models were passed to `EtoService`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const joinerConfig: Omit<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
|
|
8
|
+
//# sourceMappingURL=joiner-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,iOAAqD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinerConfig = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
/**
|
|
6
|
+
* Nothing here is queryable or linkable — `SearchIndex` and `SearchIndexSync` are
|
|
7
|
+
* the module's own bookkeeping. `models: []` has to be explicit: otherwise
|
|
8
|
+
* `defineJoinerConfig` discovers `src/models` from disk and makes it all linkable,
|
|
9
|
+
* whether or not the models were passed to `EtoService`.
|
|
10
|
+
*/
|
|
11
|
+
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.SEARCH, { models: [] });
|
|
12
|
+
//# sourceMappingURL=joiner-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joiner-config.js","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":";;;AAAA,kDAAoE;AAEpE;;;;;GAKG;AACU,QAAA,YAAY,GAAG,IAAA,0BAAkB,EAAC,eAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LoaderOptions } from "@etohq/framework/types";
|
|
2
|
+
import { SearchModuleOptions } from "../types";
|
|
3
|
+
declare const _default: ({ container, options, }: LoaderOptions<SearchModuleOptions>) => Promise<void>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,EACL,mBAAmB,EAGpB,MAAM,QAAQ,CAAA;yBAoBO,yBAGnB,aAAa,CAAC,mBAAmB,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;AAHrD,wBASC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const awilix_1 = require("awilix");
|
|
4
|
+
const modules_sdk_1 = require("@etohq/framework/modules-sdk");
|
|
5
|
+
const _services_1 = require("../services");
|
|
6
|
+
const _types_1 = require("../types");
|
|
7
|
+
const registrationFn = async (klass, container, pluginOptions) => {
|
|
8
|
+
const key = _services_1.SearchProviderService.getRegistrationIdentifier(klass, pluginOptions.id);
|
|
9
|
+
container.register({
|
|
10
|
+
[_types_1.SearchProviderRegistrationPrefix + key]: (0, awilix_1.asFunction)((cradle) => new klass(cradle, pluginOptions.options ?? {}), {
|
|
11
|
+
lifetime: klass.LIFE_TIME || awilix_1.Lifetime.SINGLETON,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
container.registerAdd(_types_1.SearchProviderIdentifiersRegistrationName, (0, awilix_1.asValue)(key));
|
|
15
|
+
};
|
|
16
|
+
exports.default = async ({ container, options, }) => {
|
|
17
|
+
await (0, modules_sdk_1.moduleProviderLoader)({
|
|
18
|
+
container,
|
|
19
|
+
providers: options?.providers || [],
|
|
20
|
+
registerServiceFn: registrationFn,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":";;AAAA,mCAAsD;AACtD,8DAAmE;AAEnE,yCAAiD;AACjD,mCAIe;AAEf,MAAM,cAAc,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE;IAC/D,MAAM,GAAG,GAAG,iCAAqB,CAAC,yBAAyB,CACzD,KAAK,EACL,aAAa,CAAC,EAAE,CACjB,CAAA;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,CAAC,yCAAgC,GAAG,GAAG,CAAC,EAAE,IAAA,mBAAU,EAClD,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC,EAC1D;YACE,QAAQ,EAAE,KAAK,CAAC,SAAS,IAAI,iBAAQ,CAAC,SAAS;SAChD,CACF;KACF,CAAC,CAAA;IAEF,SAAS,CAAC,WAAW,CAAC,kDAAyC,EAAE,IAAA,gBAAO,EAAC,GAAG,CAAC,CAAC,CAAA;AAChF,CAAC,CAAA;AAED,kBAAe,KAAK,EAAE,EACpB,SAAS,EACT,OAAO,GAC4B,EAAiB,EAAE;IACtD,MAAM,IAAA,kCAAoB,EAAC;QACzB,SAAS;QACT,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE;QACnC,iBAAiB,EAAE,cAAc;KAClC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260805085626.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20260805085626.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAErC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAanB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQrC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20260805085626 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20260805085626 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`create table if not exists "search_index" ("id" text not null, "name" text not null, "provider" text not null, "status" text check ("status" in ('pending', 'building', 'ready', 'error')) not null default 'pending', "definition_hash" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "search_index_pkey" primary key ("id"));`);
|
|
8
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_deleted_at" ON "search_index" ("deleted_at") WHERE deleted_at IS NULL;`);
|
|
9
|
+
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_search_index_name" ON "search_index" ("name") WHERE deleted_at IS NULL;`);
|
|
10
|
+
this.addSql(`create table if not exists "search_index_sync" ("id" text not null, "job_id" text null, "status" text check ("status" in ('pending', 'processing', 'done', 'failed', 'canceled')) not null default 'pending', "filters" jsonb null, "last_key" text null, "documents_synced" integer not null default 0, "started_at" timestamptz null, "completed_at" timestamptz null, "error" text null, "search_index_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "search_index_sync_pkey" primary key ("id"));`);
|
|
11
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_sync_search_index_id" ON "search_index_sync" ("search_index_id") WHERE deleted_at IS NULL;`);
|
|
12
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_sync_deleted_at" ON "search_index_sync" ("deleted_at") WHERE deleted_at IS NULL;`);
|
|
13
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_sync_job_id" ON "search_index_sync" ("job_id") WHERE deleted_at IS NULL;`);
|
|
14
|
+
this.addSql(`alter table if exists "search_index_sync" add constraint "search_index_sync_search_index_id_foreign" foreign key ("search_index_id") references "search_index" ("id") on update cascade;`);
|
|
15
|
+
}
|
|
16
|
+
async down() {
|
|
17
|
+
this.addSql(`alter table if exists "search_index_sync" drop constraint if exists "search_index_sync_search_index_id_foreign";`);
|
|
18
|
+
this.addSql(`drop table if exists "search_index" cascade;`);
|
|
19
|
+
this.addSql(`drop table if exists "search_index_sync" cascade;`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Migration20260805085626 = Migration20260805085626;
|
|
23
|
+
//# sourceMappingURL=Migration20260805085626.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260805085626.js","sourceRoot":"","sources":["../../src/migrations/Migration20260805085626.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,MAAa,uBAAwB,SAAQ,sBAAS;IAE3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC,8aAA8a,CAAC,CAAC;QAC5b,IAAI,CAAC,MAAM,CAAC,qHAAqH,CAAC,CAAC;QACnI,IAAI,CAAC,MAAM,CAAC,gHAAgH,CAAC,CAAC;QAE9H,IAAI,CAAC,MAAM,CAAC,wlBAAwlB,CAAC,CAAC;QACtmB,IAAI,CAAC,MAAM,CAAC,yIAAyI,CAAC,CAAC;QACvJ,IAAI,CAAC,MAAM,CAAC,+HAA+H,CAAC,CAAC;QAC7I,IAAI,CAAC,MAAM,CAAC,uHAAuH,CAAC,CAAC;QAErI,IAAI,CAAC,MAAM,CAAC,0LAA0L,CAAC,CAAC;IAC1M,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,kHAAkH,CAAC,CAAC;QAEhI,IAAI,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC;QAE5D,IAAI,CAAC,MAAM,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;CAEF;AAvBD,0DAuBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260903085616.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20260903085616.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAErC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBrC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20260903085616 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20260903085616 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`create table if not exists "search_index_version" ("id" text not null, "version" integer not null, "provider" text not null, "physical_name" text not null, "definition_hash" text not null, "status" text check ("status" in ('pending', 'building', 'ready', 'error')) not null default 'pending', "search_index_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "search_index_version_pkey" primary key ("id"));`);
|
|
8
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_version_search_index_id" ON "search_index_version" ("search_index_id") WHERE deleted_at IS NULL;`);
|
|
9
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_version_deleted_at" ON "search_index_version" ("deleted_at") WHERE deleted_at IS NULL;`);
|
|
10
|
+
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_search_index_version_search_index_id_version" ON "search_index_version" ("search_index_id", "version") WHERE deleted_at IS NULL;`);
|
|
11
|
+
this.addSql(`alter table if exists "search_index_version" add constraint "search_index_version_search_index_id_foreign" foreign key ("search_index_id") references "search_index" ("id") on update cascade;`);
|
|
12
|
+
this.addSql(`alter table if exists "search_index_sync" drop constraint if exists "search_index_sync_search_index_id_foreign";`);
|
|
13
|
+
this.addSql(`alter table if exists "search_index" drop column if exists "provider", drop column if exists "status", drop column if exists "definition_hash";`);
|
|
14
|
+
this.addSql(`alter table if exists "search_index" add column if not exists "active_version" integer null;`);
|
|
15
|
+
this.addSql(`drop index if exists "IDX_search_index_sync_search_index_id";`);
|
|
16
|
+
this.addSql(`alter table if exists "search_index_sync" rename column "search_index_id" to "search_index_version_id";`);
|
|
17
|
+
this.addSql(`alter table if exists "search_index_sync" add constraint "search_index_sync_search_index_version_id_foreign" foreign key ("search_index_version_id") references "search_index_version" ("id") on update cascade;`);
|
|
18
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_sync_search_index_version_id" ON "search_index_sync" ("search_index_version_id") WHERE deleted_at IS NULL;`);
|
|
19
|
+
}
|
|
20
|
+
async down() {
|
|
21
|
+
this.addSql(`alter table if exists "search_index_sync" drop constraint if exists "search_index_sync_search_index_version_id_foreign";`);
|
|
22
|
+
this.addSql(`drop table if exists "search_index_version" cascade;`);
|
|
23
|
+
this.addSql(`alter table if exists "search_index" drop column if exists "active_version";`);
|
|
24
|
+
this.addSql(`alter table if exists "search_index" add column if not exists "provider" text not null, add column if not exists "status" text check ("status" in ('pending', 'building', 'ready', 'error')) not null default 'pending', add column if not exists "definition_hash" text not null;`);
|
|
25
|
+
this.addSql(`drop index if exists "IDX_search_index_sync_search_index_version_id";`);
|
|
26
|
+
this.addSql(`alter table if exists "search_index_sync" rename column "search_index_version_id" to "search_index_id";`);
|
|
27
|
+
this.addSql(`alter table if exists "search_index_sync" add constraint "search_index_sync_search_index_id_foreign" foreign key ("search_index_id") references "search_index" ("id") on update cascade;`);
|
|
28
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_search_index_sync_search_index_id" ON "search_index_sync" ("search_index_id") WHERE deleted_at IS NULL;`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Migration20260903085616 = Migration20260903085616;
|
|
32
|
+
//# sourceMappingURL=Migration20260903085616.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260903085616.js","sourceRoot":"","sources":["../../src/migrations/Migration20260903085616.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,MAAa,uBAAwB,SAAQ,sBAAS;IAE3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC,ogBAAogB,CAAC,CAAC;QAClhB,IAAI,CAAC,MAAM,CAAC,+IAA+I,CAAC,CAAC;QAC7J,IAAI,CAAC,MAAM,CAAC,qIAAqI,CAAC,CAAC;QACnJ,IAAI,CAAC,MAAM,CAAC,yKAAyK,CAAC,CAAC;QAEvL,IAAI,CAAC,MAAM,CAAC,gMAAgM,CAAC,CAAC;QAE9M,IAAI,CAAC,MAAM,CAAC,kHAAkH,CAAC,CAAC;QAEhI,IAAI,CAAC,MAAM,CAAC,iJAAiJ,CAAC,CAAC;QAE/J,IAAI,CAAC,MAAM,CAAC,8FAA8F,CAAC,CAAC;QAE5G,IAAI,CAAC,MAAM,CAAC,+DAA+D,CAAC,CAAC;QAE7E,IAAI,CAAC,MAAM,CAAC,yGAAyG,CAAC,CAAC;QACvH,IAAI,CAAC,MAAM,CAAC,kNAAkN,CAAC,CAAC;QAChO,IAAI,CAAC,MAAM,CAAC,yJAAyJ,CAAC,CAAC;IACzK,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,0HAA0H,CAAC,CAAC;QAExI,IAAI,CAAC,MAAM,CAAC,sDAAsD,CAAC,CAAC;QAEpE,IAAI,CAAC,MAAM,CAAC,8EAA8E,CAAC,CAAC;QAE5F,IAAI,CAAC,MAAM,CAAC,oRAAoR,CAAC,CAAC;QAElS,IAAI,CAAC,MAAM,CAAC,uEAAuE,CAAC,CAAC;QAErF,IAAI,CAAC,MAAM,CAAC,yGAAyG,CAAC,CAAC;QACvH,IAAI,CAAC,MAAM,CAAC,0LAA0L,CAAC,CAAC;QACxM,IAAI,CAAC,MAAM,CAAC,yIAAyI,CAAC,CAAC;IACzJ,CAAC;CAEF;AAvCD,0DAuCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260911115931.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20260911115931.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAErC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20260911115931 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20260911115931 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`alter table if exists "search_index_sync" add column if not exists "resumable" boolean not null default true;`);
|
|
8
|
+
}
|
|
9
|
+
async down() {
|
|
10
|
+
this.addSql(`alter table if exists "search_index_sync" drop column if exists "resumable";`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Migration20260911115931 = Migration20260911115931;
|
|
14
|
+
//# sourceMappingURL=Migration20260911115931.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20260911115931.js","sourceRoot":"","sources":["../../src/migrations/Migration20260911115931.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,MAAa,uBAAwB,SAAQ,sBAAS;IAE3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC,+GAA+G,CAAC,CAAC;IAC/H,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,8EAA8E,CAAC,CAAC;IAC9F,CAAC;CAEF;AAVD,0DAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchIndexSync = exports.SearchIndexVersion = exports.SearchIndex = void 0;
|
|
4
|
+
var search_index_1 = require("./search-index");
|
|
5
|
+
Object.defineProperty(exports, "SearchIndex", { enumerable: true, get: function () { return search_index_1.SearchIndex; } });
|
|
6
|
+
var search_index_version_1 = require("./search-index-version");
|
|
7
|
+
Object.defineProperty(exports, "SearchIndexVersion", { enumerable: true, get: function () { return search_index_version_1.SearchIndexVersion; } });
|
|
8
|
+
var search_index_sync_1 = require("./search-index-sync");
|
|
9
|
+
Object.defineProperty(exports, "SearchIndexSync", { enumerable: true, get: function () { return search_index_sync_1.SearchIndexSync; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,+DAA2D;AAAlD,0HAAA,kBAAkB,OAAA;AAC3B,yDAAqD;AAA5C,oHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SearchSyncStatus } from "../utils";
|
|
2
|
+
/**
|
|
3
|
+
* Sync runs against one index version. Resuming means finding that version's
|
|
4
|
+
* most recent row and picking up from its `last_key` — but only when that row
|
|
5
|
+
* says its progress can still be picked up (see `resumable`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const SearchIndexSync: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
8
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
9
|
+
job_id: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
10
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof SearchSyncStatus>;
|
|
11
|
+
filters: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty<Record<string, unknown>>>;
|
|
12
|
+
last_key: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
13
|
+
resumable: import("@etohq/framework/utils").BooleanProperty;
|
|
14
|
+
documents_synced: import("@etohq/framework/utils").NumberProperty;
|
|
15
|
+
started_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
16
|
+
completed_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
17
|
+
error: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
18
|
+
search_index_version: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
19
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
20
|
+
version: import("@etohq/framework/utils").NumberProperty;
|
|
21
|
+
provider: import("@etohq/framework/utils").TextProperty;
|
|
22
|
+
physical_name: import("@etohq/framework/utils").TextProperty;
|
|
23
|
+
definition_hash: import("@etohq/framework/utils").TextProperty;
|
|
24
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof import("../utils").SearchIndexState>;
|
|
25
|
+
search_index: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
26
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
27
|
+
name: import("@etohq/framework/utils").TextProperty;
|
|
28
|
+
active_version: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").NumberProperty>;
|
|
29
|
+
versions: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndexVersion">>;
|
|
30
|
+
}>, "SearchIndex">, undefined>;
|
|
31
|
+
syncs: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndexSync">>;
|
|
32
|
+
}>, "SearchIndexVersion">, undefined>;
|
|
33
|
+
}>, "SearchIndexSync">;
|
|
34
|
+
//# sourceMappingURL=search-index-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index-sync.d.ts","sourceRoot":"","sources":["../../src/models/search-index-sync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;sBAkCxB,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchIndexSync = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
const utils_2 = require("../utils");
|
|
6
|
+
const search_index_version_1 = require("./search-index-version");
|
|
7
|
+
/**
|
|
8
|
+
* Sync runs against one index version. Resuming means finding that version's
|
|
9
|
+
* most recent row and picking up from its `last_key` — but only when that row
|
|
10
|
+
* says its progress can still be picked up (see `resumable`).
|
|
11
|
+
*/
|
|
12
|
+
exports.SearchIndexSync = utils_1.model
|
|
13
|
+
.define("SearchIndexSync", {
|
|
14
|
+
id: utils_1.model.id({ prefix: "srhsync" }).primaryKey(),
|
|
15
|
+
// The reindex job this run belongs to. One job may span several indexes.
|
|
16
|
+
job_id: utils_1.model.text().nullable(),
|
|
17
|
+
status: utils_1.model.enum(utils_2.SearchSyncStatus).default(utils_2.SearchSyncStatus.PENDING),
|
|
18
|
+
// Filters handed to the definition's `seed`. `null` is a full rebuild;
|
|
19
|
+
// anything else records the slice this run covered.
|
|
20
|
+
filters: utils_1.model.json().nullable(),
|
|
21
|
+
// Last primary key handed to the engine, and the resume point.
|
|
22
|
+
last_key: utils_1.model.text().nullable(),
|
|
23
|
+
// Whether a later run may continue from this row's `last_key`.
|
|
24
|
+
resumable: utils_1.model.boolean().default(true),
|
|
25
|
+
documents_synced: utils_1.model.number().default(0),
|
|
26
|
+
started_at: utils_1.model.dateTime().nullable(),
|
|
27
|
+
completed_at: utils_1.model.dateTime().nullable(),
|
|
28
|
+
error: utils_1.model.text().nullable(),
|
|
29
|
+
search_index_version: utils_1.model.belongsTo(() => search_index_version_1.SearchIndexVersion, {
|
|
30
|
+
mappedBy: "syncs",
|
|
31
|
+
}),
|
|
32
|
+
})
|
|
33
|
+
.indexes([
|
|
34
|
+
{
|
|
35
|
+
name: "IDX_search_index_sync_search_index_version_id",
|
|
36
|
+
on: ["search_index_version_id"],
|
|
37
|
+
unique: false,
|
|
38
|
+
where: "deleted_at IS NULL",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "IDX_search_index_sync_job_id",
|
|
42
|
+
on: ["job_id"],
|
|
43
|
+
unique: false,
|
|
44
|
+
where: "deleted_at IS NULL",
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
//# sourceMappingURL=search-index-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index-sync.js","sourceRoot":"","sources":["../../src/models/search-index-sync.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAC9C,oCAA2C;AAC3C,iEAA2D;AAE3D;;;;GAIG;AACU,QAAA,eAAe,GAAG,aAAK;KACjC,MAAM,CAAC,iBAAiB,EAAE;IACzB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,UAAU,EAAE;IAChD,yEAAyE;IACzE,MAAM,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,aAAK,CAAC,IAAI,CAAC,wBAAgB,CAAC,CAAC,OAAO,CAAC,wBAAgB,CAAC,OAAO,CAAC;IACtE,uEAAuE;IACvE,oDAAoD;IACpD,OAAO,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAChC,+DAA+D;IAC/D,QAAQ,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACjC,+DAA+D;IAC/D,SAAS,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACxC,gBAAgB,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,UAAU,EAAE,aAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,YAAY,EAAE,aAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC9B,oBAAoB,EAAE,aAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,yCAAkB,EAAE;QAC9D,QAAQ,EAAE,OAAO;KAClB,CAAC;CACH,CAAC;KACD,OAAO,CAAC;IACP;QACE,IAAI,EAAE,+CAA+C;QACrD,EAAE,EAAE,CAAC,yBAAyB,CAAC;QAC/B,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,IAAI,EAAE,8BAA8B;QACpC,EAAE,EAAE,CAAC,QAAQ,CAAC;QACd,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|