@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.
- package/NOTICE +24 -0
- package/README.md +189 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -17
- package/dist/index.js.map +1 -1
- 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 +2 -15
- package/dist/loaders/providers.d.ts.map +1 -1
- package/dist/loaders/providers.js +14 -37
- package/dist/loaders/providers.js.map +1 -1
- 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 +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/search-module-service.d.ts +67 -15
- package/dist/services/search-module-service.d.ts.map +1 -1
- package/dist/services/search-module-service.js +328 -12
- package/dist/services/search-module-service.js.map +1 -1
- 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 -1
- package/dist/types/index.d.ts +129 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -1
- 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 +9 -15
|
@@ -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"}
|
|
@@ -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"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +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"}
|
|
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"}
|
package/dist/services/index.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SearchModuleService = void 0;
|
|
6
|
+
exports.SearchProviderService = exports.SearchModuleService = void 0;
|
|
7
7
|
var search_module_service_1 = require("./search-module-service");
|
|
8
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; } });
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAwE;AAA/D,6IAAA,OAAO,OAAuB"}
|
|
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"}
|
|
@@ -1,20 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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>;
|
|
6
14
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* search providers and hand the active one to consumers, which reach it through
|
|
10
|
-
* the module registry (`container[Modules.SEARCH]`).
|
|
11
|
-
*/
|
|
12
|
-
export default class SearchModuleService {
|
|
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 {
|
|
13
17
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
14
|
-
protected
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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>;
|
|
18
70
|
}
|
|
19
71
|
export {};
|
|
20
72
|
//# sourceMappingURL=search-module-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-module-service.d.ts","sourceRoot":"","sources":["../../src/services/search-module-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAClC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,qBAAqB,CAAA;IAEhE,S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