Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -30,10 +30,7 @@ export function validateIndexSchema(schema: SearchIndexSchema): void {
throw new IndexSchemaValidationError("Search index schema requires a non-empty name.", "EMPTY_NAME");
}
if (typeof schema.primaryKey !== "string" || schema.primaryKey.length === 0) {
throw new IndexSchemaValidationError(
`Search index "${schema.name}" must declare a non-empty primaryKey.`,
"EMPTY_PRIMARY_KEY"
);
throw new IndexSchemaValidationError(`Search index "${schema.name}" must declare a non-empty primaryKey.`, "EMPTY_PRIMARY_KEY");
}
if (!Array.isArray(schema.filterableAttributes) || !schema.filterableAttributes.includes("tenantId")) {
throw new IndexSchemaValidationError(
@@ -56,9 +53,12 @@ export interface CreateSearchIndexInput {
readonly settingsOverride?: Partial<IndexSettingsInput>;
}
export async function createSearchIndex<TDocument extends SearchDocument = SearchDocument>(
input: CreateSearchIndexInput
): Promise<IndexHandle<TDocument>> {
export interface ProvisionSearchIndexesInput {
readonly client: SearchClient;
readonly schemas: readonly SearchIndexSchema[];
}
export async function createSearchIndex<TDocument extends SearchDocument = SearchDocument>(input: CreateSearchIndexInput): Promise<IndexHandle<TDocument>> {
validateIndexSchema(input.schema);
const settings = mergeSettings(input.schema, input.settingsOverride);
const handle = input.client.index<TDocument>(input.schema.name);
@@ -66,6 +66,17 @@ export async function createSearchIndex<TDocument extends SearchDocument = Searc
return handle;
}
/**
* Provision the complete registry before a worker accepts jobs. Waiting for
* every create/settings task keeps filtered tenant deletes from racing index
* creation or the mandatory `tenantId` filter setting.
*/
export async function provisionSearchIndexes(input: ProvisionSearchIndexesInput): Promise<void> {
for (const schema of input.schemas) {
await createSearchIndex({ client: input.client, schema });
}
}
function mergeSettings(schema: SearchIndexSchema, override: Partial<IndexSettingsInput> | undefined): IndexSettingsInput {
const base: IndexSettingsInput = {
searchableAttributes: schema.searchableAttributes,