@jini-ai/search 0.0.0-stage → 0.6.10
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 +201 -0
- package/README.md +76 -2
- package/dist/api.d.ts +92 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +2 -0
- package/dist/api.js.map +1 -0
- package/dist/contract.d.ts +219 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +46 -0
- package/dist/contract.js.map +1 -0
- package/dist/contribution.d.ts +61 -0
- package/dist/contribution.d.ts.map +1 -0
- package/dist/contribution.js +124 -0
- package/dist/contribution.js.map +1 -0
- package/dist/digest.d.ts +13 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +55 -0
- package/dist/digest.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +50 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +402 -0
- package/dist/indexer.js.map +1 -0
- package/dist/ports.d.ts +194 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +2 -0
- package/dist/ports.js.map +1 -0
- package/dist/registry.d.ts +33 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +81 -0
- package/dist/registry.js.map +1 -0
- package/dist/service.d.ts +37 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +118 -0
- package/dist/service.js.map +1 -0
- package/dist/testkit/assert.d.ts +14 -0
- package/dist/testkit/assert.d.ts.map +1 -0
- package/dist/testkit/assert.js +20 -0
- package/dist/testkit/assert.js.map +1 -0
- package/dist/testkit/conformance.d.ts +32 -0
- package/dist/testkit/conformance.d.ts.map +1 -0
- package/dist/testkit/conformance.js +453 -0
- package/dist/testkit/conformance.js.map +1 -0
- package/dist/testkit/fakes.d.ts +56 -0
- package/dist/testkit/fakes.d.ts.map +1 -0
- package/dist/testkit/fakes.js +114 -0
- package/dist/testkit/fakes.js.map +1 -0
- package/dist/testkit/index.d.ts +9 -0
- package/dist/testkit/index.d.ts.map +1 -0
- package/dist/testkit/index.js +9 -0
- package/dist/testkit/index.js.map +1 -0
- package/dist/testkit/memory-provider.d.ts +23 -0
- package/dist/testkit/memory-provider.d.ts.map +1 -0
- package/dist/testkit/memory-provider.js +237 -0
- package/dist/testkit/memory-provider.js.map +1 -0
- package/dist/tokens.d.ts +9 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +12 -0
- package/dist/tokens.js.map +1 -0
- package/dist/tools.d.ts +74 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +194 -0
- package/dist/tools.js.map +1 -0
- package/package.json +75 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The search provider registry: core's shared `createProviderRegistry` bound to the search
|
|
3
|
+
* contract, plus the one shape check every search provider (built-in, plugin, reference) passes.
|
|
4
|
+
*
|
|
5
|
+
* Registration policy is core's: a malformed or duplicate built-in throws at boot, a malformed or
|
|
6
|
+
* duplicate plugin contribution becomes a refusal line. This file only adds what is specific to
|
|
7
|
+
* search: what a well-formed {@link SearchProvider} looks like at runtime.
|
|
8
|
+
*/
|
|
9
|
+
import { type ProviderDefinition, type ProviderRegistry } from '@jini-ai/core/provider-registry';
|
|
10
|
+
import { type SearchProvider } from './contract.js';
|
|
11
|
+
export type SearchProviderRegistry = ProviderRegistry<SearchProvider>;
|
|
12
|
+
/**
|
|
13
|
+
* Runtime shape check of a search provider (the registry's `validate`, and the plugin contribution's
|
|
14
|
+
* export check). Never throws.
|
|
15
|
+
* @param required.provider - Anything; typically a plugin module's default export.
|
|
16
|
+
* @returns `undefined` when well-formed, otherwise the first reason it is not.
|
|
17
|
+
* @complexity O(credentialKeys + locales).
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateSearchProvider(required: {
|
|
20
|
+
readonly provider: unknown;
|
|
21
|
+
}, _optional?: Record<string, never>): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Build the host's search provider registry.
|
|
24
|
+
* @param optional.seed - Core (built-in) providers, registered with the throwing policy.
|
|
25
|
+
* @param optional.defaultProviderId - Defaults to the owner's built-in provider id.
|
|
26
|
+
* @throws {ProviderRegistryError} When a seed provider is malformed or duplicated.
|
|
27
|
+
* @complexity O(seed) to build; lookups O(1).
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSearchProviderRegistry(_required?: Record<string, never>, optional?: {
|
|
30
|
+
readonly seed?: readonly ProviderDefinition<SearchProvider>[];
|
|
31
|
+
readonly defaultProviderId?: string;
|
|
32
|
+
}): SearchProviderRegistry;
|
|
33
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACwC,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAC5F,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjG,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AAwCtE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,MAAM,GAAG,SAAS,CAO1I;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,EACrC,QAAQ,GAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GACpH,sBAAsB,CAKxB"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The search provider registry: core's shared `createProviderRegistry` bound to the search
|
|
3
|
+
* contract, plus the one shape check every search provider (built-in, plugin, reference) passes.
|
|
4
|
+
*
|
|
5
|
+
* Registration policy is core's: a malformed or duplicate built-in throws at boot, a malformed or
|
|
6
|
+
* duplicate plugin contribution becomes a refusal line. This file only adds what is specific to
|
|
7
|
+
* search: what a well-formed {@link SearchProvider} looks like at runtime.
|
|
8
|
+
*/
|
|
9
|
+
import { createProviderRegistry, PROVIDER_ID_PATTERN, } from '@jini-ai/core/provider-registry';
|
|
10
|
+
import { BUILTIN_SEARCH_PROVIDER_ID, SEARCH_CONTRACT } from './contract.js';
|
|
11
|
+
const CAPABILITY_FLAGS = ['acceptsRestricted', 'typoTolerance', 'asyncIndexing'];
|
|
12
|
+
const METHODS = ['ensureIndex', 'dropIndex', 'upsert', 'remove', 'query', 'revisionOf'];
|
|
13
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
14
|
+
const isStringArray = (value) => Array.isArray(value) && value.every(item => typeof item === 'string');
|
|
15
|
+
function identityFault(provider) {
|
|
16
|
+
if (typeof provider.id !== 'string' || !PROVIDER_ID_PATTERN.test(provider.id))
|
|
17
|
+
return `id must be a string matching ${PROVIDER_ID_PATTERN.source}`;
|
|
18
|
+
if (typeof provider.label !== 'string' || provider.label.trim() === '')
|
|
19
|
+
return 'label must be a non-empty string';
|
|
20
|
+
if (!isStringArray(provider.credentialKeys))
|
|
21
|
+
return 'credentialKeys must be an array of strings';
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function capabilitiesFault(capabilities) {
|
|
25
|
+
if (!isRecord(capabilities))
|
|
26
|
+
return 'capabilities must be an object';
|
|
27
|
+
const flag = CAPABILITY_FLAGS.find(name => typeof capabilities[name] !== 'boolean');
|
|
28
|
+
if (flag !== undefined)
|
|
29
|
+
return `capabilities.${flag} must be a boolean`;
|
|
30
|
+
const { maxBatch, locales } = capabilities;
|
|
31
|
+
if (typeof maxBatch !== 'number' || !Number.isSafeInteger(maxBatch) || maxBatch < 1)
|
|
32
|
+
return 'capabilities.maxBatch must be a positive integer';
|
|
33
|
+
if (locales !== 'any' && !isStringArray(locales))
|
|
34
|
+
return "capabilities.locales must be 'any' or an array of strings";
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `awaitTask` is required exactly when writes may answer `pending`; a synchronous provider may
|
|
39
|
+
* still ship one, but it must then be a function (the indexer never calls it, a wrong type is a bug).
|
|
40
|
+
*/
|
|
41
|
+
function methodsFault(provider, asyncIndexing) {
|
|
42
|
+
const missing = METHODS.find(name => typeof provider[name] !== 'function');
|
|
43
|
+
if (missing !== undefined)
|
|
44
|
+
return `${missing} must be a function`;
|
|
45
|
+
const awaitTask = provider.awaitTask;
|
|
46
|
+
if (asyncIndexing && typeof awaitTask !== 'function')
|
|
47
|
+
return 'awaitTask must be a function when capabilities.asyncIndexing is true';
|
|
48
|
+
if (awaitTask !== undefined && typeof awaitTask !== 'function')
|
|
49
|
+
return 'awaitTask must be a function when present';
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Runtime shape check of a search provider (the registry's `validate`, and the plugin contribution's
|
|
54
|
+
* export check). Never throws.
|
|
55
|
+
* @param required.provider - Anything; typically a plugin module's default export.
|
|
56
|
+
* @returns `undefined` when well-formed, otherwise the first reason it is not.
|
|
57
|
+
* @complexity O(credentialKeys + locales).
|
|
58
|
+
*/
|
|
59
|
+
export function validateSearchProvider(required, _optional = {}) {
|
|
60
|
+
const { provider } = required;
|
|
61
|
+
if (!isRecord(provider))
|
|
62
|
+
return 'a search provider must be an object';
|
|
63
|
+
return identityFault(provider)
|
|
64
|
+
?? capabilitiesFault(provider.capabilities)
|
|
65
|
+
// capabilitiesFault passed, so capabilities is a record with a boolean asyncIndexing.
|
|
66
|
+
?? methodsFault(provider, provider.capabilities.asyncIndexing === true);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the host's search provider registry.
|
|
70
|
+
* @param optional.seed - Core (built-in) providers, registered with the throwing policy.
|
|
71
|
+
* @param optional.defaultProviderId - Defaults to the owner's built-in provider id.
|
|
72
|
+
* @throws {ProviderRegistryError} When a seed provider is malformed or duplicated.
|
|
73
|
+
* @complexity O(seed) to build; lookups O(1).
|
|
74
|
+
*/
|
|
75
|
+
export function createSearchProviderRegistry(_required = {}, optional = {}) {
|
|
76
|
+
const { seed, defaultProviderId = BUILTIN_SEARCH_PROVIDER_ID } = optional;
|
|
77
|
+
return createProviderRegistry({ contract: SEARCH_CONTRACT }, {
|
|
78
|
+
defaultProviderId, validate: validateSearchProvider, ...(seed === undefined ? {} : { seed }),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,sBAAsB,EAAE,mBAAmB,GAC5C,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAuB,MAAM,eAAe,CAAC;AAIjG,MAAM,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,eAAe,EAAE,eAAe,CAAU,CAAC;AAC1F,MAAM,OAAO,GAAG,CAAC,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAU,CAAC;AAIjG,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAkB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACjG,MAAM,aAAa,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAA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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The ONE reader of every search index (lot S4).
|
|
3
|
+
*
|
|
4
|
+
* Queries the site's ACTIVE target only, under a hard deadline, and then FAILS CLOSED: a hit is
|
|
5
|
+
* returned only when it belongs to this site and workspace and the host's access port confirms it
|
|
6
|
+
* is visible right now. A provider's index may lag a publish/unpublish; the access port never does.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProviderRegistry } from '@jini-ai/core/provider-registry';
|
|
9
|
+
import { type SearchProvider, type SearchProviderContext } from './contract.js';
|
|
10
|
+
import type { SearchService } from './api.js';
|
|
11
|
+
import type { SearchAccessPort, SearchIndexStatePort, SearchTarget, SearchTargetPort } from './ports.js';
|
|
12
|
+
export interface SearchServiceRequired {
|
|
13
|
+
readonly registry: ProviderRegistry<SearchProvider>;
|
|
14
|
+
readonly targets: SearchTargetPort;
|
|
15
|
+
readonly state: SearchIndexStatePort;
|
|
16
|
+
readonly access: SearchAccessPort;
|
|
17
|
+
contextFor(required: {
|
|
18
|
+
readonly target: SearchTarget;
|
|
19
|
+
readonly workspaceId: string;
|
|
20
|
+
}): Promise<SearchProviderContext | null>;
|
|
21
|
+
}
|
|
22
|
+
export interface SearchServiceOptional {
|
|
23
|
+
/** Service deadline per query (default 3000 ms); an overrun answers `unavailable/timeout`. */
|
|
24
|
+
readonly timeoutMs?: number;
|
|
25
|
+
/** Resolves after `ms`; injected so tests control time. */
|
|
26
|
+
readonly delay?: (ms: number) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the query service.
|
|
30
|
+
* @param required - Registry, target pointer, index state, access port and the context resolver.
|
|
31
|
+
* @param optional.timeoutMs - Per-query deadline (default 3000).
|
|
32
|
+
* @param optional.delay - Timer port (default `setTimeout`).
|
|
33
|
+
* @returns The {@link SearchService} consumers receive.
|
|
34
|
+
* @complexity query O(hits) plus one provider call and one access check; status O(1) port calls.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSearchService(required: SearchServiceRequired, optional?: SearchServiceOptional): SearchService;
|
|
37
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAoC,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAoB,MAAM,eAAe,CAAC;AACpI,OAAO,KAAK,EAAE,aAAa,EAA2C,MAAM,UAAU,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEzG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,UAAU,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;CAC9H;AAED,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAiCD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,QAAQ,GAAE,qBAA0B,GAAG,aAAa,CAsExH"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { encodeSearchKey } from './contract.js';
|
|
2
|
+
const DEFAULT_LIMIT = 10;
|
|
3
|
+
const MAX_LIMIT = 100;
|
|
4
|
+
const TIMED_OUT = Symbol('timed-out');
|
|
5
|
+
const defaultDelay = (ms) => new Promise(resolve => { setTimeout(resolve, ms); });
|
|
6
|
+
/** A provider that throws despite the contract is as good as unreachable. */
|
|
7
|
+
async function guardedQuery(call) {
|
|
8
|
+
try {
|
|
9
|
+
return await call();
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 'threw';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** The provider's answer as a service result, or the page to revalidate. */
|
|
16
|
+
function pageOrFailure(result) {
|
|
17
|
+
if (result === TIMED_OUT)
|
|
18
|
+
return { status: 'unavailable', reason: 'timeout' };
|
|
19
|
+
if (result === 'threw' || result.status === 'unknown')
|
|
20
|
+
return { status: 'unavailable', reason: 'provider_unavailable' };
|
|
21
|
+
if (result.status === 'ok')
|
|
22
|
+
return result.value;
|
|
23
|
+
if (result.error.code === 'invalid_request')
|
|
24
|
+
return { status: 'invalid', message: result.error.message };
|
|
25
|
+
return { status: 'unavailable', reason: 'provider_error' };
|
|
26
|
+
}
|
|
27
|
+
/** The limit clamped to 1..100 (default 10), or the invalid result for a non-integer. */
|
|
28
|
+
function readLimit(limit) {
|
|
29
|
+
if (limit === undefined)
|
|
30
|
+
return DEFAULT_LIMIT;
|
|
31
|
+
if (!Number.isInteger(limit))
|
|
32
|
+
return { status: 'invalid', message: 'limit must be an integer' };
|
|
33
|
+
return Math.min(MAX_LIMIT, Math.max(1, limit));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the query service.
|
|
37
|
+
* @param required - Registry, target pointer, index state, access port and the context resolver.
|
|
38
|
+
* @param optional.timeoutMs - Per-query deadline (default 3000).
|
|
39
|
+
* @param optional.delay - Timer port (default `setTimeout`).
|
|
40
|
+
* @returns The {@link SearchService} consumers receive.
|
|
41
|
+
* @complexity query O(hits) plus one provider call and one access check; status O(1) port calls.
|
|
42
|
+
*/
|
|
43
|
+
export function createSearchService(required, optional = {}) {
|
|
44
|
+
const { registry, targets, state, access } = required;
|
|
45
|
+
const { timeoutMs = 3000, delay = defaultDelay } = optional;
|
|
46
|
+
/** The active target's provider and context, or null when search is not configured. */
|
|
47
|
+
const activeProvider = async (siteId, workspaceId) => {
|
|
48
|
+
const { active } = await targets.get({ siteId });
|
|
49
|
+
if (active === null)
|
|
50
|
+
return null;
|
|
51
|
+
const provider = registry.get({ id: active.providerId })?.provider;
|
|
52
|
+
if (!provider)
|
|
53
|
+
return null;
|
|
54
|
+
const ctx = await required.contextFor({ target: active, workspaceId });
|
|
55
|
+
return ctx ? { active, provider, ctx } : null;
|
|
56
|
+
};
|
|
57
|
+
/** Fail closed: only this site's and workspace's hits that the access port confirms right now. */
|
|
58
|
+
const revalidate = async (input) => {
|
|
59
|
+
const { siteId, workspaceId, page } = input;
|
|
60
|
+
// Index isolation defence: a shared vendor index or a provider bug must never leak another site.
|
|
61
|
+
const own = page.hits.filter(hit => hit.key.siteId === siteId && hit.key.workspaceId === workspaceId);
|
|
62
|
+
let visible = new Set();
|
|
63
|
+
if (own.length > 0) {
|
|
64
|
+
try {
|
|
65
|
+
visible = await access.visibleKeys({ siteId, keys: own.map(hit => hit.key), audiences: input.audiences });
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const hits = own.filter(hit => visible.has(encodeSearchKey({ key: hit.key })));
|
|
72
|
+
return page.nextCursor === undefined ? { hits } : { hits, nextCursor: page.nextCursor };
|
|
73
|
+
};
|
|
74
|
+
const targetStatus = async (target) => {
|
|
75
|
+
if (target === null)
|
|
76
|
+
return null;
|
|
77
|
+
return {
|
|
78
|
+
providerId: target.providerId, generation: target.generation,
|
|
79
|
+
registered: registry.has({ id: target.providerId }),
|
|
80
|
+
counts: await state.counts({ target }),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
async query({ siteId, workspaceId, query }, { audiences } = {}) {
|
|
85
|
+
const text = query.text.trim();
|
|
86
|
+
if (text.length === 0)
|
|
87
|
+
return { status: 'invalid', message: 'text is required' };
|
|
88
|
+
const limit = readLimit(query.limit);
|
|
89
|
+
if (typeof limit !== 'number')
|
|
90
|
+
return limit;
|
|
91
|
+
const configured = await activeProvider(siteId, workspaceId);
|
|
92
|
+
if (!configured)
|
|
93
|
+
return { status: 'unavailable', reason: 'not_configured' };
|
|
94
|
+
const { active, provider, ctx } = configured;
|
|
95
|
+
// Vendors are public-only: a viewer's audiences reach only a provider that may hold restricted
|
|
96
|
+
// content. The query object is rebuilt so a caller cannot smuggle audiences in through it.
|
|
97
|
+
const { audiences: _smuggled, ...rest } = query;
|
|
98
|
+
const effective = provider.capabilities.acceptsRestricted ? (audiences ?? []) : [];
|
|
99
|
+
const providerQuery = { ...rest, text, limit, ...(provider.capabilities.acceptsRestricted ? { audiences: effective } : {}) };
|
|
100
|
+
const raced = await Promise.race([
|
|
101
|
+
guardedQuery(() => provider.query(ctx, { query: providerQuery })),
|
|
102
|
+
delay(timeoutMs).then(() => TIMED_OUT),
|
|
103
|
+
]);
|
|
104
|
+
const answered = pageOrFailure(raced);
|
|
105
|
+
if ('status' in answered)
|
|
106
|
+
return answered;
|
|
107
|
+
const page = await revalidate({ siteId, workspaceId, page: answered, audiences: effective });
|
|
108
|
+
if (page === null)
|
|
109
|
+
return { status: 'unavailable', reason: 'access_check_failed' };
|
|
110
|
+
return { status: 'ok', providerId: active.providerId, page };
|
|
111
|
+
},
|
|
112
|
+
async status({ siteId }) {
|
|
113
|
+
const { active, building } = await targets.get({ siteId });
|
|
114
|
+
return { siteId, active: await targetStatus(active), building: await targetStatus(building) };
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# source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;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The kit's own assertion: the conformance kit must run under any test runner (vitest,
|
|
3
|
+
* node:test, jest), so it cannot import one runner's `expect`. A thrown Error fails a test in all.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SearchConformanceError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Positional rather than the house `(required, optional)` object: a TypeScript `asserts` predicate
|
|
10
|
+
* can only name a parameter, and narrowing after a check is what keeps the kit's cases readable.
|
|
11
|
+
* @throws {SearchConformanceError} with `message` when `condition` is falsy.
|
|
12
|
+
*/
|
|
13
|
+
export declare function check(condition: unknown, message: string): asserts condition;
|
|
14
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/testkit/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAE5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The kit's own assertion: the conformance kit must run under any test runner (vitest,
|
|
3
|
+
* node:test, jest), so it cannot import one runner's `expect`. A thrown Error fails a test in all.
|
|
4
|
+
*/
|
|
5
|
+
export class SearchConformanceError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(`search conformance: ${message}`);
|
|
8
|
+
this.name = 'SearchConformanceError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Positional rather than the house `(required, optional)` object: a TypeScript `asserts` predicate
|
|
13
|
+
* can only name a parameter, and narrowing after a check is what keeps the kit's cases readable.
|
|
14
|
+
* @throws {SearchConformanceError} with `message` when `condition` is falsy.
|
|
15
|
+
*/
|
|
16
|
+
export function check(condition, message) {
|
|
17
|
+
if (!condition)
|
|
18
|
+
throw new SearchConformanceError(message);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../src/testkit/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,SAAkB,EAAE,OAAe;IACvD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type SearchProvider, type SearchProviderContext } from '../contract.js';
|
|
2
|
+
/** A test registrar: `vitest`'s or `node:test`'s `test`, or any `(title, fn) => void`. */
|
|
3
|
+
export type ConformanceTestRegistrar = (title: string, fn: () => Promise<void>) => unknown;
|
|
4
|
+
export type ConformanceContextFactory = (required: {
|
|
5
|
+
readonly siteId: string;
|
|
6
|
+
readonly indexName: string;
|
|
7
|
+
}) => SearchProviderContext | Promise<SearchProviderContext>;
|
|
8
|
+
export interface SearchProviderConformanceRequired {
|
|
9
|
+
/** Prefixes every test title and index name. */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** Synchronous: capabilities decide which cases are registered, before any test runs. */
|
|
12
|
+
readonly makeProvider: () => SearchProvider;
|
|
13
|
+
/** A fresh, working context for the given site and index name. */
|
|
14
|
+
readonly makeContext: ConformanceContextFactory;
|
|
15
|
+
readonly test: ConformanceTestRegistrar;
|
|
16
|
+
}
|
|
17
|
+
export interface SearchProviderConformanceOptional {
|
|
18
|
+
/** A context under which the backend is unreachable (e.g. built on `createUnavailableHttpClient`). */
|
|
19
|
+
readonly makeUnavailableContext?: ConformanceContextFactory;
|
|
20
|
+
/** `awaitTask` polls per pending write before the kit gives up. */
|
|
21
|
+
readonly maxAwaitPolls?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Register the conformance cases for one provider with the injected test runner.
|
|
25
|
+
* @param required.makeProvider - Called once to read capabilities, then once per case.
|
|
26
|
+
* @param optional.makeUnavailableContext - Enables the unavailable-backend case.
|
|
27
|
+
* @param optional.maxAwaitPolls - Default 20.
|
|
28
|
+
* @returns The registered test titles, in order.
|
|
29
|
+
* @complexity O(cases) registrations; each case does a bounded number of provider calls.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runSearchProviderConformance(required: SearchProviderConformanceRequired, optional?: SearchProviderConformanceOptional): readonly string[];
|
|
32
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../src/testkit/conformance.ts"],"names":[],"mappings":"AAaA,OAAO,EAEyD,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAG9G,MAAM,gBAAgB,CAAC;AAIxB,0FAA0F;AAC1F,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;AAE3F,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAAK,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEtK,MAAM,WAAW,iCAAiC;IAChD,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,QAAQ,CAAC,YAAY,EAAE,MAAM,cAAc,CAAC;IAC5C,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;CACzC;AAED,MAAM,WAAW,iCAAiC;IAChD,sGAAsG;IACtG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,yBAAyB,CAAC;IAC5D,mEAAmE;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAsfD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,iCAAiC,EAAE,QAAQ,GAAE,iCAAsC,GAAG,SAAS,MAAM,EAAE,CAS7J"}
|