@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SearchIndexState } from "../utils";
|
|
2
|
+
/**
|
|
3
|
+
* One physical index ever built for a logical `SearchIndex`. Auto-incrementing
|
|
4
|
+
* per index, so `search_index.active_version` can point at whichever one
|
|
5
|
+
* currently serves reads while older or still-building versions sit beside it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SearchIndexVersion: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
8
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
9
|
+
version: import("@etohq/framework/utils").NumberProperty;
|
|
10
|
+
provider: import("@etohq/framework/utils").TextProperty;
|
|
11
|
+
physical_name: import("@etohq/framework/utils").TextProperty;
|
|
12
|
+
definition_hash: import("@etohq/framework/utils").TextProperty;
|
|
13
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof SearchIndexState>;
|
|
14
|
+
search_index: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
15
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
16
|
+
name: import("@etohq/framework/utils").TextProperty;
|
|
17
|
+
active_version: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").NumberProperty>;
|
|
18
|
+
versions: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndexVersion">>;
|
|
19
|
+
}>, "SearchIndex">, undefined>;
|
|
20
|
+
syncs: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
21
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
22
|
+
job_id: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
23
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof import("../utils").SearchSyncStatus>;
|
|
24
|
+
filters: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty<Record<string, unknown>>>;
|
|
25
|
+
last_key: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
26
|
+
resumable: import("@etohq/framework/utils").BooleanProperty;
|
|
27
|
+
documents_synced: import("@etohq/framework/utils").NumberProperty;
|
|
28
|
+
started_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
29
|
+
completed_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
30
|
+
error: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
31
|
+
search_index_version: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndexVersion">, undefined>;
|
|
32
|
+
}>, "SearchIndexSync">>;
|
|
33
|
+
}>, "SearchIndexVersion">;
|
|
34
|
+
//# sourceMappingURL=search-index-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index-version.d.ts","sourceRoot":"","sources":["../../src/models/search-index-version.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAI3C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuB3B,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchIndexVersion = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
const utils_2 = require("../utils");
|
|
6
|
+
const search_index_1 = require("./search-index");
|
|
7
|
+
const search_index_sync_1 = require("./search-index-sync");
|
|
8
|
+
/**
|
|
9
|
+
* One physical index ever built for a logical `SearchIndex`. Auto-incrementing
|
|
10
|
+
* per index, so `search_index.active_version` can point at whichever one
|
|
11
|
+
* currently serves reads while older or still-building versions sit beside it.
|
|
12
|
+
*/
|
|
13
|
+
exports.SearchIndexVersion = utils_1.model
|
|
14
|
+
.define("SearchIndexVersion", {
|
|
15
|
+
id: utils_1.model.id({ prefix: "srhver" }).primaryKey(),
|
|
16
|
+
version: utils_1.model.number(),
|
|
17
|
+
// The identifier of the provider backing this version.
|
|
18
|
+
provider: utils_1.model.text(),
|
|
19
|
+
// The physical index/table/namespace this version was built under.
|
|
20
|
+
physical_name: utils_1.model.text(),
|
|
21
|
+
// Used to detect schema drift against the loaded definition.
|
|
22
|
+
definition_hash: utils_1.model.text(),
|
|
23
|
+
status: utils_1.model.enum(utils_2.SearchIndexState).default(utils_2.SearchIndexState.PENDING),
|
|
24
|
+
search_index: utils_1.model.belongsTo(() => search_index_1.SearchIndex, { mappedBy: "versions" }),
|
|
25
|
+
syncs: utils_1.model.hasMany(() => search_index_sync_1.SearchIndexSync, {
|
|
26
|
+
mappedBy: "search_index_version",
|
|
27
|
+
}),
|
|
28
|
+
})
|
|
29
|
+
.indexes([
|
|
30
|
+
{
|
|
31
|
+
name: "IDX_search_index_version_search_index_id_version",
|
|
32
|
+
on: ["search_index_id", "version"],
|
|
33
|
+
unique: true,
|
|
34
|
+
where: "deleted_at IS NULL",
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
//# sourceMappingURL=search-index-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index-version.js","sourceRoot":"","sources":["../../src/models/search-index-version.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAC9C,oCAA2C;AAC3C,iDAA4C;AAC5C,2DAAqD;AAErD;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,aAAK;KACpC,MAAM,CAAC,oBAAoB,EAAE;IAC5B,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE;IAC/C,OAAO,EAAE,aAAK,CAAC,MAAM,EAAE;IACvB,uDAAuD;IACvD,QAAQ,EAAE,aAAK,CAAC,IAAI,EAAE;IACtB,mEAAmE;IACnE,aAAa,EAAE,aAAK,CAAC,IAAI,EAAE;IAC3B,6DAA6D;IAC7D,eAAe,EAAE,aAAK,CAAC,IAAI,EAAE;IAC7B,MAAM,EAAE,aAAK,CAAC,IAAI,CAAC,wBAAgB,CAAC,CAAC,OAAO,CAAC,wBAAgB,CAAC,OAAO,CAAC;IACtE,YAAY,EAAE,aAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,0BAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC1E,KAAK,EAAE,aAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,mCAAe,EAAE;QAC1C,QAAQ,EAAE,sBAAsB;KACjC,CAAC;CACH,CAAC;KACD,OAAO,CAAC;IACP;QACE,IAAI,EAAE,kDAAkD;QACxD,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC;QAClC,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const SearchIndex: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
3
|
+
name: import("@etohq/framework/utils").TextProperty;
|
|
4
|
+
active_version: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").NumberProperty>;
|
|
5
|
+
versions: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
6
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
7
|
+
version: import("@etohq/framework/utils").NumberProperty;
|
|
8
|
+
provider: import("@etohq/framework/utils").TextProperty;
|
|
9
|
+
physical_name: import("@etohq/framework/utils").TextProperty;
|
|
10
|
+
definition_hash: import("@etohq/framework/utils").TextProperty;
|
|
11
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof import("../utils").SearchIndexState>;
|
|
12
|
+
search_index: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndex">, undefined>;
|
|
13
|
+
syncs: import("@etohq/framework/utils").HasMany<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
14
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
15
|
+
job_id: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
16
|
+
status: import("@etohq/framework/utils").EnumProperty<typeof import("../utils").SearchSyncStatus>;
|
|
17
|
+
filters: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty<Record<string, unknown>>>;
|
|
18
|
+
last_key: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
19
|
+
resumable: import("@etohq/framework/utils").BooleanProperty;
|
|
20
|
+
documents_synced: import("@etohq/framework/utils").NumberProperty;
|
|
21
|
+
started_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
22
|
+
completed_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
23
|
+
error: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
24
|
+
search_index_version: import("@etohq/framework/utils").BelongsTo<() => import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder</*elided*/ any>, "SearchIndexVersion">, undefined>;
|
|
25
|
+
}>, "SearchIndexSync">>;
|
|
26
|
+
}>, "SearchIndexVersion">>;
|
|
27
|
+
}>, "SearchIndex">;
|
|
28
|
+
//# sourceMappingURL=search-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index.d.ts","sourceRoot":"","sources":["../../src/models/search-index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqBpB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchIndex = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
const search_index_version_1 = require("./search-index-version");
|
|
6
|
+
exports.SearchIndex = utils_1.model
|
|
7
|
+
.define("SearchIndex", {
|
|
8
|
+
id: utils_1.model.id({ prefix: "srhidx" }).primaryKey(),
|
|
9
|
+
// The index name, as used in `query.search({ entity })`.
|
|
10
|
+
// For now we expect the index and entity names to match.
|
|
11
|
+
name: utils_1.model.text(),
|
|
12
|
+
// The version number of this index's version that serves reads. `null`
|
|
13
|
+
// until the first version finishes seeding.
|
|
14
|
+
active_version: utils_1.model.number().nullable(),
|
|
15
|
+
// Every physical index ever built for this logical index, in order.
|
|
16
|
+
versions: utils_1.model.hasMany(() => search_index_version_1.SearchIndexVersion, {
|
|
17
|
+
mappedBy: "search_index",
|
|
18
|
+
}),
|
|
19
|
+
})
|
|
20
|
+
.indexes([
|
|
21
|
+
{
|
|
22
|
+
name: "IDX_search_index_name",
|
|
23
|
+
on: ["name"],
|
|
24
|
+
unique: true,
|
|
25
|
+
where: "deleted_at IS NULL",
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
//# sourceMappingURL=search-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-index.js","sourceRoot":"","sources":["../../src/models/search-index.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAC9C,iEAA2D;AAE9C,QAAA,WAAW,GAAG,aAAK;KAC7B,MAAM,CAAC,aAAa,EAAE;IACrB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE;IAC/C,yDAAyD;IACzD,yDAAyD;IACzD,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE;IAClB,uEAAuE;IACvE,4CAA4C;IAC5C,cAAc,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzC,oEAAoE;IACpE,QAAQ,EAAE,aAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,yCAAkB,EAAE;QAChD,QAAQ,EAAE,cAAc;KACzB,CAAC;CACH,CAAC;KACD,OAAO,CAAC;IACP;QACE,IAAI,EAAE,uBAAuB;QAC7B,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
exports.SearchProviderService = exports.SearchModuleService = void 0;
|
|
7
|
+
var search_module_service_1 = require("./search-module-service");
|
|
8
|
+
Object.defineProperty(exports, "SearchModuleService", { enumerable: true, get: function () { return __importDefault(search_module_service_1).default; } });
|
|
9
|
+
var search_provider_1 = require("./search-provider");
|
|
10
|
+
Object.defineProperty(exports, "SearchProviderService", { enumerable: true, get: function () { return search_provider_1.SearchProviderService; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAwE;AAA/D,6IAAA,OAAO,OAAuB;AACvC,qDAAyD;AAAhD,wHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Event, IEventBusModuleService, InternalModuleDeclaration, Logger, ModuleJoinerConfig, ModulesSdkTypes, RemoteQueryFunction, SearchTypes } from "@etohq/framework/types";
|
|
2
|
+
import { ContainerRegistrationKeys, Modules } from "@etohq/framework/utils";
|
|
3
|
+
import { SearchEventRoutes, SearchIndexContext, SearchIndexes, SearchIndexSeedAction, SearchModuleOptions } from "../types";
|
|
4
|
+
import { ActiveIndexVersion, ActiveIndexVersionCache } from "../utils/active-version-cache";
|
|
5
|
+
import { SearchProviderService } from "./search-provider";
|
|
6
|
+
type InjectedDependencies = {
|
|
7
|
+
logger: Logger;
|
|
8
|
+
[Modules.EVENT_BUS]: IEventBusModuleService;
|
|
9
|
+
[ContainerRegistrationKeys.QUERY]: RemoteQueryFunction;
|
|
10
|
+
searchProviderService: SearchProviderService;
|
|
11
|
+
searchIndexService: ModulesSdkTypes.IEtoInternalService<any>;
|
|
12
|
+
searchIndexVersionService: ModulesSdkTypes.IEtoInternalService<any>;
|
|
13
|
+
searchIndexSyncService: ModulesSdkTypes.IEtoInternalService<any>;
|
|
14
|
+
};
|
|
15
|
+
declare const SearchModuleService_base: import("@etohq/framework/utils").EtoServiceReturnType<import("@etohq/framework/utils").ModelConfigurationsToConfigTemplate<{}>>;
|
|
16
|
+
export default class SearchModuleService extends SearchModuleService_base implements SearchTypes.ISearchModuleService {
|
|
17
|
+
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
18
|
+
protected isWorkerMode: boolean;
|
|
19
|
+
protected readonly logger_: Logger;
|
|
20
|
+
protected readonly searchProviderService_: SearchProviderService;
|
|
21
|
+
protected readonly moduleOptions_: SearchModuleOptions;
|
|
22
|
+
protected readonly indexes_: SearchIndexes;
|
|
23
|
+
protected readonly activeVersionCache_: ActiveIndexVersionCache;
|
|
24
|
+
protected readonly context_: SearchIndexContext;
|
|
25
|
+
protected readonly eventRoutes_: SearchEventRoutes;
|
|
26
|
+
protected readonly eventBus_?: IEventBusModuleService;
|
|
27
|
+
constructor(container: InjectedDependencies, moduleOptions: SearchModuleOptions, moduleDeclaration: InternalModuleDeclaration);
|
|
28
|
+
protected fetchActiveVersions_(container: InjectedDependencies): Promise<Map<string, ActiveIndexVersion>>;
|
|
29
|
+
protected resolveActiveDefinition_(name: string, options?: {
|
|
30
|
+
fresh?: boolean;
|
|
31
|
+
}): Promise<SearchTypes.ResolvedSearchIndexDefinition>;
|
|
32
|
+
__joinerConfig(): ModuleJoinerConfig;
|
|
33
|
+
__hooks: {
|
|
34
|
+
onApplicationStart: () => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Eto has no subscriber directory to drop an ingestion subscriber into, so the
|
|
38
|
+
* module subscribes to the events its definitions declare itself. Only a
|
|
39
|
+
* worker ingests, like a subscriber would; awaiting `ingest` acknowledges
|
|
40
|
+
* the event, so a failed write is redelivered.
|
|
41
|
+
*/
|
|
42
|
+
protected subscribeToIndexEvents_(): void;
|
|
43
|
+
search<T = Record<string, unknown>>(query: SearchTypes.SearchQuery): Promise<SearchTypes.SearchResult<T>>;
|
|
44
|
+
searchMany(queries: SearchTypes.SearchQuery[]): Promise<SearchTypes.SearchResult[]>;
|
|
45
|
+
protected searchMany_(queries: SearchTypes.SearchQuery[]): Promise<SearchTypes.SearchResult[]>;
|
|
46
|
+
upsertDocuments({ index, documents, }: {
|
|
47
|
+
index: string;
|
|
48
|
+
documents: SearchTypes.SearchDocument[];
|
|
49
|
+
}): Promise<SearchTypes.SearchTask>;
|
|
50
|
+
deleteDocuments({ index, filters, }: {
|
|
51
|
+
index: string;
|
|
52
|
+
filters: SearchTypes.SearchFilters;
|
|
53
|
+
}): Promise<SearchTypes.SearchTask>;
|
|
54
|
+
ingest(event: Event<any>): Promise<SearchTypes.SearchTask[]>;
|
|
55
|
+
listIndexes(): Promise<SearchTypes.SearchIndexDetails[]>;
|
|
56
|
+
listRetrievableFields(index: string): string[];
|
|
57
|
+
getIndex(index: string): SearchTypes.ResolvedSearchIndexDefinition;
|
|
58
|
+
reindex(input?: SearchTypes.SearchReindexInput): Promise<SearchTypes.SearchReindexResult>;
|
|
59
|
+
deleteIndex(index: string): Promise<SearchTypes.SearchIndexDeleteResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Seeds whatever needs data. Indexes that are not migrated yet are skipped —
|
|
62
|
+
* creating and migrating physical indexes is the application's job
|
|
63
|
+
* (e.g. `db:migrate`), not something a booting worker invents.
|
|
64
|
+
*/
|
|
65
|
+
protected onApplicationStart_(): Promise<void>;
|
|
66
|
+
protected createSeedPlan_(): Promise<SearchIndexSeedAction[]>;
|
|
67
|
+
protected executeSeedPlan_(actions: SearchIndexSeedAction[]): Promise<void>;
|
|
68
|
+
createIndexMigrationPlan(): Promise<SearchTypes.SearchIndexMigrationAction[]>;
|
|
69
|
+
executeIndexMigrationPlan(actions: SearchTypes.SearchIndexMigrationAction[]): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=search-module-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-module-service.d.ts","sourceRoot":"","sources":["../../src/services/search-module-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,sBAAsB,EACtB,yBAAyB,EACzB,MAAM,EACN,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,WAAW,EACZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,yBAAyB,EAGzB,OAAO,EAER,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EAEb,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,QAAQ,CAAA;AAgBf,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAatC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAA;IAC3C,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAA;IACtD,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,kBAAkB,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC5D,yBAAyB,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACnE,sBAAsB,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;CACjE,CAAA;;AAED,MAAM,CAAC,OAAO,OAAO,mBAInB,SAAQ,wBACR,YAAW,WAAW,CAAC,oBAAoB;IA+BzC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;IA7BjE,SAAS,CAAC,YAAY,EAAE,OAAO,CAAO;IAEtC,SAAS,CAAC,QAA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
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
+
const _utils_1 = require("../utils");
|
|
5
|
+
const active_version_cache_1 = require("../utils/active-version-cache");
|
|
6
|
+
const deletion_1 = require("../utils/deletion");
|
|
7
|
+
const ingestion_1 = require("../utils/ingestion");
|
|
8
|
+
const migrations_1 = require("../utils/migrations");
|
|
9
|
+
const seeding_1 = require("../utils/seeding");
|
|
10
|
+
const joiner_config_1 = require("../joiner-config");
|
|
11
|
+
class SearchModuleService
|
|
12
|
+
// Deliberately no models: `SearchIndex` and `SearchIndexSync` are the module's
|
|
13
|
+
// own bookkeeping, so they get no generated CRUD and are not linkable. They are
|
|
14
|
+
// still discovered from `src/models` for migrations.
|
|
15
|
+
extends (0, utils_1.EtoService)({}) {
|
|
16
|
+
constructor(container, moduleOptions, moduleDeclaration) {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.moduleDeclaration = moduleDeclaration;
|
|
20
|
+
this.isWorkerMode = true;
|
|
21
|
+
this.__hooks = {
|
|
22
|
+
onApplicationStart: async () => {
|
|
23
|
+
this.subscribeToIndexEvents_();
|
|
24
|
+
// Seeding can take a long time on a large catalog and must not delay the
|
|
25
|
+
// worker from accepting jobs. Failures are logged rather than blocking boot.
|
|
26
|
+
void this.onApplicationStart_().catch((error) => {
|
|
27
|
+
this.logger_.error(`[Search] Failed to seed search indexes: ${error.message}`, error);
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
this.logger_ = container.logger ?? console;
|
|
32
|
+
this.searchProviderService_ = container.searchProviderService;
|
|
33
|
+
this.moduleOptions_ = (moduleOptions ??
|
|
34
|
+
moduleDeclaration.options ??
|
|
35
|
+
{});
|
|
36
|
+
// `worker_mode` is stamped onto every module's declaration by the
|
|
37
|
+
// modules-sdk from the application's own `projectConfig.workerMode`, so this
|
|
38
|
+
// reads the same value `configModule` would give — an HTTP-only process
|
|
39
|
+
// must not spend its boot seeding indexes.
|
|
40
|
+
this.isWorkerMode = moduleDeclaration.worker_mode !== "server";
|
|
41
|
+
// Resolved here rather than on application start, so anything that resolves the
|
|
42
|
+
// module — `db:migrate` included — sees the definitions without booting first.
|
|
43
|
+
this.indexes_ = this.moduleOptions_.indexes?.length
|
|
44
|
+
? (0, _utils_1.resolveIndexDefinitions)({
|
|
45
|
+
definitions: this.moduleOptions_.indexes,
|
|
46
|
+
default_provider: container.searchProviderService.getDefaultIdentifier(this.moduleOptions_.default_provider),
|
|
47
|
+
index_prefix: this.moduleOptions_.index_prefix,
|
|
48
|
+
})
|
|
49
|
+
: new Map();
|
|
50
|
+
this.eventRoutes_ = (0, ingestion_1.buildEventRoutes)(this.indexes_);
|
|
51
|
+
this.eventBus_ = resolveEventBus(container);
|
|
52
|
+
this.activeVersionCache_ = new active_version_cache_1.ActiveIndexVersionCache(() => this.fetchActiveVersions_(container));
|
|
53
|
+
this.context_ = {
|
|
54
|
+
container: {
|
|
55
|
+
get query() {
|
|
56
|
+
return container[utils_1.ContainerRegistrationKeys.QUERY];
|
|
57
|
+
},
|
|
58
|
+
logger: this.logger_,
|
|
59
|
+
},
|
|
60
|
+
logger: this.logger_,
|
|
61
|
+
options: this.moduleOptions_,
|
|
62
|
+
indexes: this.indexes_,
|
|
63
|
+
providers: container.searchProviderService,
|
|
64
|
+
indexService: container.searchIndexService,
|
|
65
|
+
versionService: container.searchIndexVersionService,
|
|
66
|
+
syncService: container.searchIndexSyncService,
|
|
67
|
+
locking: resolveLocking(container),
|
|
68
|
+
activeVersionCache: this.activeVersionCache_,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Reads the DB directly, for every index at once — there are never many
|
|
72
|
+
// search indexes in an app, so listing them all is cheap, and it lets one
|
|
73
|
+
// refresh (triggered by any index) serve every index. Called by
|
|
74
|
+
// `activeVersionCache_` on a cache miss or refresh — never on the request
|
|
75
|
+
// path itself.
|
|
76
|
+
async fetchActiveVersions_(container) {
|
|
77
|
+
const records = (await container.searchIndexService.list({}, { take: null }));
|
|
78
|
+
const versionsByIndexId = await (0, _utils_1.listVersionsByIndexId)({ versionService: container.searchIndexVersionService }, records.map((record) => record.id));
|
|
79
|
+
const values = new Map();
|
|
80
|
+
for (const record of records) {
|
|
81
|
+
if (record.active_version == null) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const version = versionsByIndexId
|
|
85
|
+
.get(record.id)
|
|
86
|
+
?.find((candidate) => candidate.version === record.active_version);
|
|
87
|
+
if (version) {
|
|
88
|
+
values.set(record.name, {
|
|
89
|
+
physical_name: version.physical_name,
|
|
90
|
+
provider: version.provider,
|
|
91
|
+
version: version.version,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return values;
|
|
96
|
+
}
|
|
97
|
+
// Merges in the physical index and provider currently serving reads. Every
|
|
98
|
+
// *live* read or write goes through this rather than `definition.physical_name`
|
|
99
|
+
// directly, since the active version can change out from under this process.
|
|
100
|
+
// Shared with the ingestion path (`resolveActiveDefinition` in `@utils`) so
|
|
101
|
+
// the two can't drift apart.
|
|
102
|
+
async resolveActiveDefinition_(name, options = {}) {
|
|
103
|
+
return await (0, _utils_1.resolveActiveDefinition)(this.context_, name, options);
|
|
104
|
+
}
|
|
105
|
+
// Declared so that `Module()` does not derive one by scanning `src/models`,
|
|
106
|
+
// which would make the module's bookkeeping linkable.
|
|
107
|
+
__joinerConfig() {
|
|
108
|
+
return joiner_config_1.joinerConfig;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Eto has no subscriber directory to drop an ingestion subscriber into, so the
|
|
112
|
+
* module subscribes to the events its definitions declare itself. Only a
|
|
113
|
+
* worker ingests, like a subscriber would; awaiting `ingest` acknowledges
|
|
114
|
+
* the event, so a failed write is redelivered.
|
|
115
|
+
*/
|
|
116
|
+
subscribeToIndexEvents_() {
|
|
117
|
+
if (!this.isWorkerMode || !this.eventBus_ || !this.eventRoutes_.size) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const subscriber = async (event) => {
|
|
121
|
+
await this.ingest(event);
|
|
122
|
+
};
|
|
123
|
+
for (const eventName of this.eventRoutes_.keys()) {
|
|
124
|
+
this.eventBus_.subscribe(eventName, subscriber, {
|
|
125
|
+
subscriberId: `search-ingestion-${eventName}`,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async search(query) {
|
|
130
|
+
const [result] = await this.searchMany([query]);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
async searchMany(queries) {
|
|
134
|
+
if (!queries.length) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
// Reads take the cached version, so this one can be pointed at a version
|
|
138
|
+
// that has since been dropped. That surfaces as a `NOT_FOUND` from the
|
|
139
|
+
// engine, and the retry resolves it again rather than failing the search.
|
|
140
|
+
return await (0, _utils_1.withActiveIndexRetry)(this.context_, () => this.searchMany_(queries));
|
|
141
|
+
}
|
|
142
|
+
async searchMany_(queries) {
|
|
143
|
+
const prepared = await (0, utils_1.promiseAll)(queries.map(async (query) => {
|
|
144
|
+
const index = await this.resolveActiveDefinition_(query.entity);
|
|
145
|
+
const normalized = (0, _utils_1.normalizeSearchQuery)({ query, index });
|
|
146
|
+
const provider = this.searchProviderService_.retrieve(index.provider);
|
|
147
|
+
// Whether the *provider* can serve the query is the provider's call, made
|
|
148
|
+
// while it translates. This only checks the query against the definition,
|
|
149
|
+
// which is provider-independent.
|
|
150
|
+
(0, _utils_1.validateFieldUsage)({ index, query: normalized });
|
|
151
|
+
return { normalized, provider };
|
|
152
|
+
}));
|
|
153
|
+
const flattened = [];
|
|
154
|
+
prepared.forEach(({ normalized, provider }, originalIndex) => {
|
|
155
|
+
if (!normalized.search_options?.disjunctive_facets) {
|
|
156
|
+
flattened.push({ provider, query: normalized, originalIndex });
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const { base, per_facet } = (0, _utils_1.buildDisjunctiveFacetQueries)(normalized);
|
|
160
|
+
flattened.push({ provider, query: base, originalIndex });
|
|
161
|
+
for (const [field, facetQuery] of per_facet) {
|
|
162
|
+
flattened.push({
|
|
163
|
+
provider,
|
|
164
|
+
query: facetQuery,
|
|
165
|
+
originalIndex,
|
|
166
|
+
facetField: field,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const groups = new Map();
|
|
171
|
+
flattened.forEach((item, flatIndex) => {
|
|
172
|
+
const group = groups.get(item.provider);
|
|
173
|
+
if (group) {
|
|
174
|
+
group.push({ item, flatIndex });
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
groups.set(item.provider, [{ item, flatIndex }]);
|
|
178
|
+
});
|
|
179
|
+
const flatResults = new Array(flattened.length);
|
|
180
|
+
await (0, utils_1.promiseAll)([...groups].map(async ([provider, group]) => {
|
|
181
|
+
const inputs = group.map(({ item }) => item.query);
|
|
182
|
+
const results = provider.searchMany
|
|
183
|
+
? await provider.searchMany(inputs)
|
|
184
|
+
: await (0, utils_1.promiseAll)(inputs.map((input) => provider.search(input)));
|
|
185
|
+
group.forEach(({ flatIndex }, i) => {
|
|
186
|
+
flatResults[flatIndex] = results[i];
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
189
|
+
const results = new Array(queries.length);
|
|
190
|
+
const pendingFacets = new Map();
|
|
191
|
+
flattened.forEach((item, flatIndex) => {
|
|
192
|
+
if (!item.facetField) {
|
|
193
|
+
results[item.originalIndex] = flatResults[flatIndex];
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const perFacet = pendingFacets.get(item.originalIndex) ?? new Map();
|
|
197
|
+
perFacet.set(item.facetField, flatResults[flatIndex]);
|
|
198
|
+
pendingFacets.set(item.originalIndex, perFacet);
|
|
199
|
+
});
|
|
200
|
+
for (const [index, perFacet] of pendingFacets) {
|
|
201
|
+
results[index] = (0, _utils_1.mergeDisjunctiveFacetResults)({
|
|
202
|
+
base: results[index],
|
|
203
|
+
per_facet: perFacet,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return results;
|
|
207
|
+
}
|
|
208
|
+
async upsertDocuments({ index, documents, }) {
|
|
209
|
+
if (!documents.length) {
|
|
210
|
+
return { index, status: "succeeded" };
|
|
211
|
+
}
|
|
212
|
+
return await (0, _utils_1.withActiveIndexRetry)(this.context_, async () => {
|
|
213
|
+
const definition = await this.resolveActiveDefinition_(index, {
|
|
214
|
+
fresh: true,
|
|
215
|
+
});
|
|
216
|
+
const provider = this.searchProviderService_.retrieve(definition.provider);
|
|
217
|
+
const task = await provider.upsertDocuments({
|
|
218
|
+
index: definition.physical_name,
|
|
219
|
+
definition,
|
|
220
|
+
documents,
|
|
221
|
+
});
|
|
222
|
+
return (0, _utils_1.assertTaskAccepted)(task, index);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async deleteDocuments({ index, filters, }) {
|
|
226
|
+
if (!filters || !Object.keys(filters).length) {
|
|
227
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `Deleting from search index "${index}" requires filters; pass { id: [...] } to delete by id, or clear the index through a reindex`);
|
|
228
|
+
}
|
|
229
|
+
return await (0, _utils_1.withActiveIndexRetry)(this.context_, async () => {
|
|
230
|
+
const definition = await this.resolveActiveDefinition_(index, {
|
|
231
|
+
fresh: true,
|
|
232
|
+
});
|
|
233
|
+
const provider = this.searchProviderService_.retrieve(definition.provider);
|
|
234
|
+
const task = await provider.deleteDocuments({
|
|
235
|
+
index: definition.physical_name,
|
|
236
|
+
filters,
|
|
237
|
+
});
|
|
238
|
+
return (0, _utils_1.assertTaskAccepted)(task, index);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// Waits for its writes, so awaiting this acknowledges the event.
|
|
242
|
+
async ingest(event) {
|
|
243
|
+
return await (0, ingestion_1.ingestEvent)(this.context_, {
|
|
244
|
+
event,
|
|
245
|
+
routes: this.eventRoutes_,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
async listIndexes() {
|
|
249
|
+
const definitions = [...this.indexes_.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
250
|
+
if (!definitions.length) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
const records = (await this.context_.indexService.list({ name: definitions.map((definition) => definition.name) }, { take: null }));
|
|
254
|
+
const byName = new Map(records.map((record) => [record.name, record]));
|
|
255
|
+
const versionsByIndexId = await (0, _utils_1.listVersionsByIndexId)(this.context_, records.map((record) => record.id));
|
|
256
|
+
return definitions.map((definition) => {
|
|
257
|
+
const record = byName.get(definition.name);
|
|
258
|
+
const versions = record ? versionsByIndexId.get(record.id) ?? [] : [];
|
|
259
|
+
const activeVersion = record?.active_version != null
|
|
260
|
+
? versions.find((version) => version.version === record.active_version)
|
|
261
|
+
: undefined;
|
|
262
|
+
return {
|
|
263
|
+
name: definition.name,
|
|
264
|
+
entity: definition.entity,
|
|
265
|
+
provider: activeVersion?.provider ?? definition.provider,
|
|
266
|
+
status: (activeVersion?.status ??
|
|
267
|
+
_utils_1.SearchIndexState.PENDING),
|
|
268
|
+
fields: (0, _utils_1.listIndexedFields)(definition.fields),
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
listRetrievableFields(index) {
|
|
273
|
+
return (0, _utils_1.listRetrievablePaths)((0, _utils_1.retrieveIndexDefinition)(this.indexes_, index).fields);
|
|
274
|
+
}
|
|
275
|
+
getIndex(index) {
|
|
276
|
+
return (0, _utils_1.retrieveIndexDefinition)(this.indexes_, index);
|
|
277
|
+
}
|
|
278
|
+
async reindex(input = {}) {
|
|
279
|
+
return await (0, seeding_1.reindexIndexes)(this.context_, input);
|
|
280
|
+
}
|
|
281
|
+
async deleteIndex(index) {
|
|
282
|
+
return await (0, deletion_1.deleteIndexEntirely)(this.context_, index);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Seeds whatever needs data. Indexes that are not migrated yet are skipped —
|
|
286
|
+
* creating and migrating physical indexes is the application's job
|
|
287
|
+
* (e.g. `db:migrate`), not something a booting worker invents.
|
|
288
|
+
*/
|
|
289
|
+
async onApplicationStart_() {
|
|
290
|
+
if (!this.indexes_.size || !this.isWorkerMode) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const seeds = await this.createSeedPlan_();
|
|
294
|
+
if (!seeds.length) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this.logger_.info(`[Search] Seeding ${seeds.length} index(es): ${seeds
|
|
298
|
+
.map((seed) => `${seed.index} (${seed.reason})`)
|
|
299
|
+
.join(", ")}`);
|
|
300
|
+
await this.executeSeedPlan_(seeds);
|
|
301
|
+
}
|
|
302
|
+
async createSeedPlan_() {
|
|
303
|
+
return await (0, seeding_1.createSeedPlan)(this.context_);
|
|
304
|
+
}
|
|
305
|
+
async executeSeedPlan_(actions) {
|
|
306
|
+
await (0, seeding_1.executeSeedPlan)(this.context_, actions);
|
|
307
|
+
}
|
|
308
|
+
async createIndexMigrationPlan() {
|
|
309
|
+
return await (0, migrations_1.createIndexMigrationPlan)(this.context_);
|
|
310
|
+
}
|
|
311
|
+
async executeIndexMigrationPlan(actions) {
|
|
312
|
+
await (0, migrations_1.executeIndexMigrationPlan)(this.context_, actions);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.default = SearchModuleService;
|
|
316
|
+
// The event bus is a declared dependency, but a module loaded on its own (or in
|
|
317
|
+
// tests) may run without one.
|
|
318
|
+
function resolveEventBus(container) {
|
|
319
|
+
try {
|
|
320
|
+
return container[utils_1.Modules.EVENT_BUS];
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// The Locking Module is optional, and reading a missing registration off the
|
|
327
|
+
// container throws rather than returning undefined.
|
|
328
|
+
function resolveLocking(container) {
|
|
329
|
+
try {
|
|
330
|
+
return container[utils_1.Modules.LOCKING];
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=search-module-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-module-service.js","sourceRoot":"","sources":["../../src/services/search-module-service.ts"],"names":[],"mappings":";;AAUA,kDAM+B;AAS/B,mCAce;AACf,wEAGsC;AACtC,gDAAuD;AACvD,kDAAkE;AAClE,oDAG4B;AAC5B,8CAIyB;AACzB,oDAA+C;AAa/C,MAAqB,mBAAmB;AACtC,+EAA+E;AAC/E,gFAAgF;AAChF,qDAAqD;AACrD,SAAQ,IAAA,kBAAU,EAAC,EAAE,CAAC;IA6BtB,YACE,SAA+B,EAC/B,aAAkC,EACf,iBAA4C;QAE/D,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QAHA,sBAAiB,GAAjB,iBAAiB,CAA2B;QA7BvD,iBAAY,GAAY,IAAI,CAAA;QAiJtC,YAAO,GAAG;YACR,kBAAkB,EAAE,KAAK,IAAI,EAAE;gBAC7B,IAAI,CAAC,uBAAuB,EAAE,CAAA;gBAE9B,yEAAyE;gBACzE,6EAA6E;gBAC7E,KAAK,IAAI,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC9C,IAAI,CAAC,OAAO,CAAC,KAAK,CAChB,2CAA2C,KAAK,CAAC,OAAO,EAAE,EAC1D,KAAK,CACN,CAAA;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;QA5HC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,IAAK,OAA6B,CAAA;QACjE,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC,qBAAqB,CAAA;QAE7D,IAAI,CAAC,cAAc,GAAG,CAAC,aAAa;YAClC,iBAAiB,CAAC,OAAO;YACzB,EAAE,CAA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CAAC;QACH,OAAO,SAAS,CAAC,eAAO,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,oDAAoD;AACpD,SAAS,cAAc,CACrB,SAA+B;IAE/B,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,eAAO,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Constructor, SearchTypes } from "@etohq/framework/types";
|
|
2
|
+
import { SearchProviderRegistrationPrefix } from "../types";
|
|
3
|
+
type InjectedDependencies = {
|
|
4
|
+
[key: `${typeof SearchProviderRegistrationPrefix}${string}`]: SearchTypes.ISearchProvider;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Registry over the registered providers. Multiple providers can be used, and
|
|
8
|
+
* each index can select which provider to use for itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SearchProviderService {
|
|
11
|
+
protected readonly providers_: Map<string, SearchTypes.ISearchProvider>;
|
|
12
|
+
constructor(container: InjectedDependencies);
|
|
13
|
+
static getRegistrationIdentifier(providerClass: Constructor<SearchTypes.ISearchProvider>, optionName?: string): string;
|
|
14
|
+
retrieve(identifier: string): SearchTypes.ISearchProvider;
|
|
15
|
+
list(): SearchTypes.ISearchProvider[];
|
|
16
|
+
/**
|
|
17
|
+
* Used by definitions that do not name a provider. Resolves to the sole
|
|
18
|
+
* registered provider, or to the module's `default_provider` option.
|
|
19
|
+
*/
|
|
20
|
+
getDefaultIdentifier(configured?: string): string;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=search-provider.d.ts.map
|