@etohq/search 2.0.4 → 2.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.
Files changed (92) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +189 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -17
  6. package/dist/index.js.map +1 -1
  7. package/dist/joiner-config.d.ts +8 -0
  8. package/dist/joiner-config.d.ts.map +1 -0
  9. package/dist/joiner-config.js +12 -0
  10. package/dist/joiner-config.js.map +1 -0
  11. package/dist/loaders/providers.d.ts +2 -15
  12. package/dist/loaders/providers.d.ts.map +1 -1
  13. package/dist/loaders/providers.js +14 -37
  14. package/dist/loaders/providers.js.map +1 -1
  15. package/dist/migrations/Migration20260805085626.d.ts +6 -0
  16. package/dist/migrations/Migration20260805085626.d.ts.map +1 -0
  17. package/dist/migrations/Migration20260805085626.js +23 -0
  18. package/dist/migrations/Migration20260805085626.js.map +1 -0
  19. package/dist/migrations/Migration20260903085616.d.ts +6 -0
  20. package/dist/migrations/Migration20260903085616.d.ts.map +1 -0
  21. package/dist/migrations/Migration20260903085616.js +32 -0
  22. package/dist/migrations/Migration20260903085616.js.map +1 -0
  23. package/dist/migrations/Migration20260911115931.d.ts +6 -0
  24. package/dist/migrations/Migration20260911115931.d.ts.map +1 -0
  25. package/dist/migrations/Migration20260911115931.js +14 -0
  26. package/dist/migrations/Migration20260911115931.js.map +1 -0
  27. package/dist/models/index.d.ts +4 -0
  28. package/dist/models/index.d.ts.map +1 -0
  29. package/dist/models/index.js +10 -0
  30. package/dist/models/index.js.map +1 -0
  31. package/dist/models/search-index-sync.d.ts +34 -0
  32. package/dist/models/search-index-sync.d.ts.map +1 -0
  33. package/dist/models/search-index-sync.js +47 -0
  34. package/dist/models/search-index-sync.js.map +1 -0
  35. package/dist/models/search-index-version.d.ts +34 -0
  36. package/dist/models/search-index-version.d.ts.map +1 -0
  37. package/dist/models/search-index-version.js +37 -0
  38. package/dist/models/search-index-version.js.map +1 -0
  39. package/dist/models/search-index.d.ts +28 -0
  40. package/dist/models/search-index.d.ts.map +1 -0
  41. package/dist/models/search-index.js +28 -0
  42. package/dist/models/search-index.js.map +1 -0
  43. package/dist/services/index.d.ts +1 -0
  44. package/dist/services/index.d.ts.map +1 -1
  45. package/dist/services/index.js +3 -1
  46. package/dist/services/index.js.map +1 -1
  47. package/dist/services/search-module-service.d.ts +67 -15
  48. package/dist/services/search-module-service.d.ts.map +1 -1
  49. package/dist/services/search-module-service.js +328 -12
  50. package/dist/services/search-module-service.js.map +1 -1
  51. package/dist/services/search-provider.d.ts +23 -0
  52. package/dist/services/search-provider.d.ts.map +1 -0
  53. package/dist/services/search-provider.js +64 -0
  54. package/dist/services/search-provider.js.map +1 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/dist/types/index.d.ts +129 -6
  57. package/dist/types/index.d.ts.map +1 -1
  58. package/dist/types/index.js +4 -0
  59. package/dist/types/index.js.map +1 -1
  60. package/dist/utils/active-version-cache.d.ts +36 -0
  61. package/dist/utils/active-version-cache.d.ts.map +1 -0
  62. package/dist/utils/active-version-cache.js +73 -0
  63. package/dist/utils/active-version-cache.js.map +1 -0
  64. package/dist/utils/deletion.d.ts +11 -0
  65. package/dist/utils/deletion.d.ts.map +1 -0
  66. package/dist/utils/deletion.js +50 -0
  67. package/dist/utils/deletion.js.map +1 -0
  68. package/dist/utils/index.d.ts +88 -0
  69. package/dist/utils/index.d.ts.map +1 -0
  70. package/dist/utils/index.js +524 -0
  71. package/dist/utils/index.js.map +1 -0
  72. package/dist/utils/ingestion.d.ts +12 -0
  73. package/dist/utils/ingestion.d.ts.map +1 -0
  74. package/dist/utils/ingestion.js +78 -0
  75. package/dist/utils/ingestion.js.map +1 -0
  76. package/dist/utils/migrations.d.ts +5 -0
  77. package/dist/utils/migrations.d.ts.map +1 -0
  78. package/dist/utils/migrations.js +143 -0
  79. package/dist/utils/migrations.js.map +1 -0
  80. package/dist/utils/rate-limit.d.ts +9 -0
  81. package/dist/utils/rate-limit.d.ts.map +1 -0
  82. package/dist/utils/rate-limit.js +47 -0
  83. package/dist/utils/rate-limit.js.map +1 -0
  84. package/dist/utils/seeding.d.ts +29 -0
  85. package/dist/utils/seeding.d.ts.map +1 -0
  86. package/dist/utils/seeding.js +639 -0
  87. package/dist/utils/seeding.js.map +1 -0
  88. package/dist/utils/versions.d.ts +50 -0
  89. package/dist/utils/versions.d.ts.map +1 -0
  90. package/dist/utils/versions.js +113 -0
  91. package/dist/utils/versions.js.map +1 -0
  92. package/package.json +9 -15
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 ADDED
@@ -0,0 +1,189 @@
1
+ # @etohq/search
2
+
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 CHANGED
@@ -1,3 +1,4 @@
1
+ import "./types";
1
2
  import { SearchModuleService } from "./services";
2
3
  declare const _default: import("@etohq/types").ModuleExports<typeof SearchModuleService> & {
3
4
  linkable: Record<string, any>;
@@ -8,5 +9,4 @@ declare const _default: import("@etohq/types").ModuleExports<typeof SearchModule
8
9
  };
9
10
  };
10
11
  export default _default;
11
- export * from "./types";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;;;;;;;;;AAEhD,wBAGE;AAEF,cAAc,SAAS,CAAA"}
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 CHANGED
@@ -1,28 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
19
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ require("./types");
20
7
  const utils_1 = require("@etohq/framework/utils");
8
+ const _services_1 = require("./services");
21
9
  const providers_1 = __importDefault(require("./loaders/providers"));
22
- const services_1 = require("./services");
23
10
  exports.default = (0, utils_1.Module)(utils_1.Modules.SEARCH, {
24
- service: services_1.SearchModuleService,
11
+ service: _services_1.SearchModuleService,
25
12
  loaders: [providers_1.default],
26
13
  });
27
- __exportStar(require("./types"), exports);
28
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,kDAAwD;AAExD,oEAA+C;AAC/C,yCAAgD;AAEhD,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,MAAM,EAAE;IACpC,OAAO,EAAE,8BAAmB;IAC5B,OAAO,EAAE,CAAC,mBAAa,CAAC;CACzB,CAAC,CAAA;AAEF,0CAAuB"}
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"}
@@ -1,18 +1,5 @@
1
- import type { LoaderOptions } from "@etohq/framework/types";
2
- import type { SearchModuleOptions } from "../types";
3
- /**
4
- * Loads the configured search providers and registers the active one.
5
- *
6
- * Search is its own module (not the entity index): providers are retrieval
7
- * engines, and the module owns their registration the way the notification
8
- * module owns notification providers.
9
- */
10
- /** Prefix for each provider's container registration. */
11
- export declare const SearchProviderPrefix = "search_provider_";
12
- /** Container key holding the ids of the loaded providers. */
13
- export declare const SearchProviderIdentifiers = "searchProviderIds";
14
- /** Container key the module service reads for the active provider. */
15
- export declare const SearchServiceRegistrationName = "searchService";
1
+ import { LoaderOptions } from "@etohq/framework/types";
2
+ import { SearchModuleOptions } from "../types";
16
3
  declare const _default: ({ container, options, }: LoaderOptions<SearchModuleOptions>) => Promise<void>;
17
4
  export default _default;
18
5
  //# sourceMappingURL=providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAI3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;;GAMG;AAEH,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AAEtD,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB,sBAAsB,CAAA;AAE5D,sEAAsE;AACtE,eAAO,MAAM,6BAA6B,kBAAkB,CAAA;yBAOtC,yBAGnB,aAAa,CAAC,mBAAmB,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;AAHrD,wBA+CC"}
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"}
@@ -1,46 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchServiceRegistrationName = exports.SearchProviderIdentifiers = exports.SearchProviderPrefix = void 0;
4
- const modules_sdk_1 = require("@etohq/framework/modules-sdk");
5
- const utils_1 = require("@etohq/framework/utils");
6
3
  const awilix_1 = require("awilix");
7
- /**
8
- * Loads the configured search providers and registers the active one.
9
- *
10
- * Search is its own module (not the entity index): providers are retrieval
11
- * engines, and the module owns their registration the way the notification
12
- * module owns notification providers.
13
- */
14
- /** Prefix for each provider's container registration. */
15
- exports.SearchProviderPrefix = "search_provider_";
16
- /** Container key holding the ids of the loaded providers. */
17
- exports.SearchProviderIdentifiers = "searchProviderIds";
18
- /** Container key the module service reads for the active provider. */
19
- exports.SearchServiceRegistrationName = "searchService";
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
+ };
20
16
  exports.default = async ({ container, options, }) => {
21
- container.registerAdd(exports.SearchProviderIdentifiers, (0, awilix_1.asValue)(undefined));
22
- const providers = options?.providers ?? [];
23
- const registered = new Map();
24
17
  await (0, modules_sdk_1.moduleProviderLoader)({
25
18
  container,
26
- providers: providers,
27
- registerServiceFn: async (klass, cradleContainer, moduleDetails) => {
28
- const id = moduleDetails?.id ?? (0, utils_1.lowerCaseFirst)(klass.name);
29
- const providerOptions = (moduleDetails?.options ?? {});
30
- registered.set(id, { klass, options: providerOptions });
31
- cradleContainer.register({
32
- [`${exports.SearchProviderPrefix}${id}`]: (0, awilix_1.asFunction)((cradle) => new klass(cradle, providerOptions), { lifetime: klass.LIFE_TIME || awilix_1.Lifetime.SINGLETON }),
33
- });
34
- cradleContainer.registerAdd(exports.SearchProviderIdentifiers, (0, awilix_1.asValue)(id));
35
- },
36
- });
37
- const activeId = options?.searchProvider ?? providers[0]?.id;
38
- const active = activeId ? registered.get(activeId) : undefined;
39
- if (!active) {
40
- return;
41
- }
42
- container.register({
43
- [exports.SearchServiceRegistrationName]: (0, awilix_1.asFunction)((cradle) => new active.klass(cradle, active.options), { lifetime: awilix_1.Lifetime.SINGLETON }),
19
+ providers: options?.providers || [],
20
+ registerServiceFn: registrationFn,
44
21
  });
45
22
  };
46
23
  //# sourceMappingURL=providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":";;;AAAA,8DAAmE;AAEnE,kDAAuD;AACvD,mCAAsD;AAItD;;;;;;GAMG;AAEH,yDAAyD;AAC5C,QAAA,oBAAoB,GAAG,kBAAkB,CAAA;AAEtD,6DAA6D;AAChD,QAAA,yBAAyB,GAAG,mBAAmB,CAAA;AAE5D,sEAAsE;AACzD,QAAA,6BAA6B,GAAG,eAAe,CAAA;AAO5D,kBAAe,KAAK,EAAE,EACpB,SAAS,EACT,OAAO,GAC4B,EAAiB,EAAE;IACtD,SAAS,CAAC,WAAW,CAAC,iCAAyB,EAAE,IAAA,gBAAO,EAAC,SAAS,CAAC,CAAC,CAAA;IAEpE,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,EAAE,CAAA;IAC1C,MAAM,UAAU,GAAG,IAAI,GAAG,EAGvB,CAAA;IAEH,MAAM,IAAA,kCAAoB,EAAC;QACzB,SAAS;QACT,SAAS,EAAE,SAAkB;QAC7B,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE;YACjE,MAAM,EAAE,GAAG,aAAa,EAAE,EAAE,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC1D,MAAM,eAAe,GAAG,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,CAGpD,CAAA;YAED,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAA;YAEvD,eAAe,CAAC,QAAQ,CAAC;gBACvB,CAAC,GAAG,4BAAoB,GAAG,EAAE,EAAE,CAAC,EAAE,IAAA,mBAAU,EAC1C,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,EAC9C,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,IAAI,iBAAQ,CAAC,SAAS,EAAE,CACpD;aACF,CAAC,CAAA;YAEF,eAAe,CAAC,WAAW,CAAC,iCAAyB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,CAAA;QACrE,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,OAAO,EAAE,cAAc,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAM;IACR,CAAC;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,CAAC,qCAA6B,CAAC,EAAE,IAAA,mBAAU,EACzC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EACpD,EAAE,QAAQ,EAAE,iBAAQ,CAAC,SAAS,EAAE,CACjC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
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,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20260805085626 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20260805085626.d.ts.map
@@ -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,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20260903085616 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20260903085616.d.ts.map
@@ -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,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20260911115931 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20260911115931.d.ts.map
@@ -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,4 @@
1
+ export { SearchIndex } from "./search-index";
2
+ export { SearchIndexVersion } from "./search-index-version";
3
+ export { SearchIndexSync } from "./search-index-sync";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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"}