@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
package/dist/contract.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sha256Hex } from './digest.js';
|
|
2
|
+
/** The contract name used by the provider registry and plugin contributions. */
|
|
3
|
+
export const SEARCH_CONTRACT = 'search';
|
|
4
|
+
/** The id the owner's in-process provider registers under; also the per-site default. */
|
|
5
|
+
export const BUILTIN_SEARCH_PROVIDER_ID = 'builtin';
|
|
6
|
+
const SEP = '/';
|
|
7
|
+
/**
|
|
8
|
+
* The single string form of a key, for maps, state rows and vendor document ids. Each part is
|
|
9
|
+
* `encodeURIComponent`-ed so a `/` inside a part can never forge another key.
|
|
10
|
+
* @complexity O(total key length).
|
|
11
|
+
*/
|
|
12
|
+
export function encodeSearchKey(required) {
|
|
13
|
+
const { siteId, workspaceId, collection, documentId } = required.key;
|
|
14
|
+
return [siteId, workspaceId, collection, documentId].map(part => encodeURIComponent(part)).join(SEP);
|
|
15
|
+
}
|
|
16
|
+
/** Inverse of {@link encodeSearchKey}; `undefined` for anything that is not exactly four parts. */
|
|
17
|
+
export function decodeSearchKey(required) {
|
|
18
|
+
const parts = required.encoded.split(SEP);
|
|
19
|
+
if (parts.length !== 4)
|
|
20
|
+
return undefined;
|
|
21
|
+
try {
|
|
22
|
+
const [siteId, workspaceId, collection, documentId] = parts.map(part => decodeURIComponent(part));
|
|
23
|
+
return { siteId, workspaceId, collection, documentId };
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The backend index name for one install, site, provider and generation. Derived from the install
|
|
31
|
+
* id (never the site slug) so two installs sharing a vendor account cannot collide, and the
|
|
32
|
+
* generation suffix is what makes a provider switch or full rebuild an atomic pointer flip.
|
|
33
|
+
* The identity is a SHA-256 digest (160 bits kept) of the COMPLETE, unambiguously encoded
|
|
34
|
+
* (installId, siteId, providerId) tuple: a lossy slug (`site-a` vs `site_a`, two long ids sharing a
|
|
35
|
+
* prefix) would give two sites one index, and dropping one site's generation would delete the
|
|
36
|
+
* other's. The generation stays a distinct, readable suffix, never truncated; the provider prefix is
|
|
37
|
+
* only a readable label.
|
|
38
|
+
* Output grammar `[a-z0-9_]`, at most 120 chars (fits Meilisearch and Algolia index-name rules).
|
|
39
|
+
* @complexity O(input length).
|
|
40
|
+
*/
|
|
41
|
+
export function searchIndexName(required) {
|
|
42
|
+
const label = required.providerId.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '').slice(0, 24) || 'x';
|
|
43
|
+
const identity = sha256Hex({ text: JSON.stringify([required.installId, required.siteId, required.providerId]) }).slice(0, 40);
|
|
44
|
+
return `js_${label}_${identity}_g${required.generation}`;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,gFAAgF;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC,yFAAyF;AACzF,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAuK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AS,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9H,OAAO,MAAM,KAAK,IAAI,QAAQ,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Plugin-contributed search providers (subpath `@jini-ai/search/contribution`, node).
|
|
3
|
+
*
|
|
4
|
+
* A plugin ships a manifest at its package root naming plain-JS provider modules:
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* { "schemaVersion": 1, "providers": [{ "id": "meilisearch", "label": "Meilisearch", "module": "dist/provider.mjs" }] }
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* The host loads it through the one executable loader (activation, bundled digest, contained path)
|
|
11
|
+
* and offers the results to its registry:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const definition = defineSearchProviderContribution({ filename: 'host-search-providers.json' });
|
|
15
|
+
* const loaded = await loader.loadPluginContributions({ workspaceId, definition });
|
|
16
|
+
* const { accepted, refusals } = contributeProviders({ registry, loaded }); // re-exported below
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Every fault (bad JSON, bad entry, duplicate id, bad export, restricted vendor, id mismatch) is a
|
|
20
|
+
* refusal string, never a throw: a broken plugin must not crash boot.
|
|
21
|
+
*/
|
|
22
|
+
import { defineProviderContribution, type LoadedProviderContribution, type PluginContributionDefinition, type PluginContributionParseResult, type ProviderContributionDescriptor } from '@jini-ai/agent-plugins/lifecycle';
|
|
23
|
+
import { type SearchProvider } from './contract.js';
|
|
24
|
+
export { contributeProviders } from '@jini-ai/agent-plugins/lifecycle';
|
|
25
|
+
export declare const SEARCH_PROVIDER_MANIFEST_SCHEMA_VERSION = 1;
|
|
26
|
+
export interface SearchProviderDescriptor extends ProviderContributionDescriptor {
|
|
27
|
+
readonly label: string;
|
|
28
|
+
}
|
|
29
|
+
export type SearchProviderContributionDefinition = PluginContributionDefinition<SearchProviderDescriptor, LoadedProviderContribution<SearchProvider>>;
|
|
30
|
+
/**
|
|
31
|
+
* Parse a search provider manifest. The id grammar is checked later, per entry, before its module
|
|
32
|
+
* is imported (so one bad id refuses one provider, not the whole manifest).
|
|
33
|
+
* @complexity O(entries).
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseSearchProviderManifest(required: {
|
|
36
|
+
readonly raw: string;
|
|
37
|
+
}, _optional?: Record<string, never>): PluginContributionParseResult<SearchProviderDescriptor>;
|
|
38
|
+
/**
|
|
39
|
+
* The module's default export as a search provider, or why not.
|
|
40
|
+
*
|
|
41
|
+
* Why vendors may not declare `acceptsRestricted`: a plugin provider sends documents to a third
|
|
42
|
+
* party the site owner does not operate, and audience filtering there would rest on that vendor's
|
|
43
|
+
* filter semantics and key handling. Restricted (members-only, audience-limited) content therefore
|
|
44
|
+
* only ever lives in the host's own built-in provider, which is registered by the composition root
|
|
45
|
+
* as a core provider and never through this path. Refusing the flag here keeps the indexer's
|
|
46
|
+
* public-only routing honest: a plugin cannot opt itself into receiving restricted documents.
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateContributedSearchProvider(required: {
|
|
49
|
+
readonly exported: unknown;
|
|
50
|
+
}, _optional?: Record<string, never>): SearchProvider | string;
|
|
51
|
+
/**
|
|
52
|
+
* Define the search provider contribution for a host-chosen manifest filename.
|
|
53
|
+
* @param required.filename - The manifest file a plugin ships at its package root.
|
|
54
|
+
* @param optional - The loader's read/import recovery policy, passed through unchanged.
|
|
55
|
+
* @returns A definition for `loadPluginContributions`; its items go to `contributeProviders`.
|
|
56
|
+
* @complexity O(1); each load is one contained import per declared provider.
|
|
57
|
+
*/
|
|
58
|
+
export declare function defineSearchProviderContribution(required: {
|
|
59
|
+
readonly filename: string;
|
|
60
|
+
}, optional?: Parameters<typeof defineProviderContribution<SearchProviderDescriptor, SearchProvider>>[1]): SearchProviderContributionDefinition;
|
|
61
|
+
//# sourceMappingURL=contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../src/contribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,0BAA0B,EAAE,KAAK,0BAA0B,EAAE,KAAK,4BAA4B,EAC9F,KAAK,6BAA6B,EAAE,KAAK,8BAA8B,EACxE,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,eAAO,MAAM,uCAAuC,IAAI,CAAC;AAEzD,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,oCAAoC,GAAG,4BAA4B,CAAC,wBAAwB,EAAE,0BAA0B,CAAC,cAAc,CAAC,CAAC,CAAC;AAsBtJ;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,6BAA6B,CAAC,wBAAwB,CAAC,CAe9K;AAED;;;;;;;;;GASG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,cAAc,GAAG,MAAM,CAM1J;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EACvC,QAAQ,GAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAM,GACxG,oCAAoC,CAkBtC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Plugin-contributed search providers (subpath `@jini-ai/search/contribution`, node).
|
|
3
|
+
*
|
|
4
|
+
* A plugin ships a manifest at its package root naming plain-JS provider modules:
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* { "schemaVersion": 1, "providers": [{ "id": "meilisearch", "label": "Meilisearch", "module": "dist/provider.mjs" }] }
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* The host loads it through the one executable loader (activation, bundled digest, contained path)
|
|
11
|
+
* and offers the results to its registry:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const definition = defineSearchProviderContribution({ filename: 'host-search-providers.json' });
|
|
15
|
+
* const loaded = await loader.loadPluginContributions({ workspaceId, definition });
|
|
16
|
+
* const { accepted, refusals } = contributeProviders({ registry, loaded }); // re-exported below
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Every fault (bad JSON, bad entry, duplicate id, bad export, restricted vendor, id mismatch) is a
|
|
20
|
+
* refusal string, never a throw: a broken plugin must not crash boot.
|
|
21
|
+
*/
|
|
22
|
+
import { defineProviderContribution, } from '@jini-ai/agent-plugins/lifecycle';
|
|
23
|
+
import { SEARCH_CONTRACT } from './contract.js';
|
|
24
|
+
import { validateSearchProvider } from './registry.js';
|
|
25
|
+
export { contributeProviders } from '@jini-ai/agent-plugins/lifecycle';
|
|
26
|
+
export const SEARCH_PROVIDER_MANIFEST_SCHEMA_VERSION = 1;
|
|
27
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
28
|
+
/** Relative, forward-looking `.mjs` path; on-disk containment is still enforced by the loader at import. */
|
|
29
|
+
const isRelativeModule = (value) => value.endsWith('.mjs') && !/^([/\\]|[A-Za-z]:)/.test(value);
|
|
30
|
+
/** One manifest entry, or why it is invalid. Unknown keys are ignored (only these three are kept). */
|
|
31
|
+
function parseEntry(entry, index) {
|
|
32
|
+
if (!isRecord(entry))
|
|
33
|
+
return `providers[${index}] must be an object`;
|
|
34
|
+
const { id, label, module } = entry;
|
|
35
|
+
if (typeof id !== 'string')
|
|
36
|
+
return `providers[${index}].id must be a string`;
|
|
37
|
+
if (typeof label !== 'string' || label.trim() === '')
|
|
38
|
+
return `providers[${index}].label must be a non-empty string`;
|
|
39
|
+
if (typeof module !== 'string' || !isRelativeModule(module))
|
|
40
|
+
return `providers[${index}].module must be a relative .mjs path`;
|
|
41
|
+
return { id, label, module };
|
|
42
|
+
}
|
|
43
|
+
function parseJson(raw) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(raw);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse a search provider manifest. The id grammar is checked later, per entry, before its module
|
|
53
|
+
* is imported (so one bad id refuses one provider, not the whole manifest).
|
|
54
|
+
* @complexity O(entries).
|
|
55
|
+
*/
|
|
56
|
+
export function parseSearchProviderManifest(required, _optional = {}) {
|
|
57
|
+
const manifest = parseJson(required.raw);
|
|
58
|
+
if (!isRecord(manifest))
|
|
59
|
+
return { ok: false, reason: 'it must be a JSON object' };
|
|
60
|
+
if (manifest.schemaVersion !== SEARCH_PROVIDER_MANIFEST_SCHEMA_VERSION)
|
|
61
|
+
return { ok: false, reason: `schemaVersion must be ${SEARCH_PROVIDER_MANIFEST_SCHEMA_VERSION}` };
|
|
62
|
+
if (!Array.isArray(manifest.providers))
|
|
63
|
+
return { ok: false, reason: 'providers must be an array' };
|
|
64
|
+
const descriptors = [];
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for (const [index, entry] of manifest.providers.entries()) {
|
|
67
|
+
const parsed = parseEntry(entry, index);
|
|
68
|
+
if (typeof parsed === 'string')
|
|
69
|
+
return { ok: false, reason: parsed };
|
|
70
|
+
if (seen.has(parsed.id))
|
|
71
|
+
return { ok: false, reason: `provider id '${parsed.id}' is declared twice` };
|
|
72
|
+
seen.add(parsed.id);
|
|
73
|
+
descriptors.push(parsed);
|
|
74
|
+
}
|
|
75
|
+
return { ok: true, descriptors };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The module's default export as a search provider, or why not.
|
|
79
|
+
*
|
|
80
|
+
* Why vendors may not declare `acceptsRestricted`: a plugin provider sends documents to a third
|
|
81
|
+
* party the site owner does not operate, and audience filtering there would rest on that vendor's
|
|
82
|
+
* filter semantics and key handling. Restricted (members-only, audience-limited) content therefore
|
|
83
|
+
* only ever lives in the host's own built-in provider, which is registered by the composition root
|
|
84
|
+
* as a core provider and never through this path. Refusing the flag here keeps the indexer's
|
|
85
|
+
* public-only routing honest: a plugin cannot opt itself into receiving restricted documents.
|
|
86
|
+
*/
|
|
87
|
+
export function validateContributedSearchProvider(required, _optional = {}) {
|
|
88
|
+
const reason = validateSearchProvider({ provider: required.exported });
|
|
89
|
+
if (reason !== undefined)
|
|
90
|
+
return `its module's default export is not a search provider: ${reason}`;
|
|
91
|
+
const provider = required.exported;
|
|
92
|
+
if (provider.capabilities.acceptsRestricted)
|
|
93
|
+
return 'a plugin provider must not accept restricted content (only the built-in provider may)';
|
|
94
|
+
return provider;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Define the search provider contribution for a host-chosen manifest filename.
|
|
98
|
+
* @param required.filename - The manifest file a plugin ships at its package root.
|
|
99
|
+
* @param optional - The loader's read/import recovery policy, passed through unchanged.
|
|
100
|
+
* @returns A definition for `loadPluginContributions`; its items go to `contributeProviders`.
|
|
101
|
+
* @complexity O(1); each load is one contained import per declared provider.
|
|
102
|
+
*/
|
|
103
|
+
export function defineSearchProviderContribution(required, optional = {}) {
|
|
104
|
+
const base = defineProviderContribution({
|
|
105
|
+
contract: SEARCH_CONTRACT, filename: required.filename,
|
|
106
|
+
parse: parseSearchProviderManifest, validate: validateContributedSearchProvider,
|
|
107
|
+
}, optional);
|
|
108
|
+
return {
|
|
109
|
+
...base,
|
|
110
|
+
load: async (input) => {
|
|
111
|
+
const loaded = await base.load(input);
|
|
112
|
+
if (typeof loaded === 'string')
|
|
113
|
+
return loaded;
|
|
114
|
+
const { descriptor, plugin } = input;
|
|
115
|
+
const providerId = loaded.definition.provider.id;
|
|
116
|
+
// The registry keys by the manifest id while services and settings name the provider by its
|
|
117
|
+
// own id; a mismatch would make one provider answer under two names.
|
|
118
|
+
if (providerId === descriptor.id)
|
|
119
|
+
return loaded;
|
|
120
|
+
return `${SEARCH_CONTRACT} provider '${descriptor.id}' from '${plugin.pluginId}' was not loaded: its module's provider id '${providerId}' differs from the manifest id`;
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.js","sourceRoot":"","sources":["../src/contribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,0BAA0B,GAE3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAuB,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC;AASzD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAkB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAE1H,4GAA4G;AAC5G,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,KAAK,CA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AE,OAAO,uFAAuF,CAAC;IAC5I,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,QAAuC,EACvC,WAAuG,EAAE;IAEzG,MAAM,IAAI,GAAG,0BAA0B,CAA2C;QAChF,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QACtD,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,iCAAiC;KAChF,EAAE,QAAQ,CAAC,CAAC;IACb,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,OAAO,MAAM,KAAK,QAAQ;gBAAE,OAAO,MAAM,CAAC;YAC9C,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YACrC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjD,4FAA4F;YAC5F,qEAAqE;YACrE,IAAI,UAAU,KAAK,UAAU,CAAC,EAAE;gBAAE,OAAO,MAAM,CAAC;YAChD,OAAO,GAAG,eAAe,cAAc,UAAU,CAAC,EAAE,WAAW,MAAM,CAAC,QAAQ,+CAA+C,UAAU,gCAAgC,CAAC;QAC1K,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/digest.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SHA-256 (FIPS 180-4) over a string's UTF-8 bytes, synchronous and dependency-free, so the
|
|
3
|
+
* universal entry point needs neither `node:crypto` nor the async WebCrypto API. Used for index
|
|
4
|
+
* names, where a collision-resistant digest of the full identity is required (not for secrets).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lower-case hex SHA-256 of `required.text`'s UTF-8 encoding.
|
|
8
|
+
* @complexity O(text length).
|
|
9
|
+
*/
|
|
10
|
+
export declare function sha256Hex(required: {
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}, _optional?: Record<string, never>): string;
|
|
13
|
+
//# sourceMappingURL=digest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0CH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,MAAM,CAM5G"}
|
package/dist/digest.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SHA-256 (FIPS 180-4) over a string's UTF-8 bytes, synchronous and dependency-free, so the
|
|
3
|
+
* universal entry point needs neither `node:crypto` nor the async WebCrypto API. Used for index
|
|
4
|
+
* names, where a collision-resistant digest of the full identity is required (not for secrets).
|
|
5
|
+
*/
|
|
6
|
+
const K = Uint32Array.from([
|
|
7
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
8
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
9
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
10
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
11
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
12
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
13
|
+
]);
|
|
14
|
+
const rotr = (x, n) => (x >>> n) | (x << (32 - n));
|
|
15
|
+
/** The message padded to whole 64-byte blocks, its bit length in the last 8 bytes (big-endian). */
|
|
16
|
+
function pad(bytes) {
|
|
17
|
+
const length = Math.ceil((bytes.length + 9) / 64) * 64;
|
|
18
|
+
const padded = new Uint8Array(length);
|
|
19
|
+
padded.set(bytes);
|
|
20
|
+
padded[bytes.length] = 0x80;
|
|
21
|
+
const view = new DataView(padded.buffer);
|
|
22
|
+
view.setUint32(length - 8, Math.floor(bytes.length / 0x20000000));
|
|
23
|
+
view.setUint32(length - 4, (bytes.length * 8) >>> 0);
|
|
24
|
+
return view;
|
|
25
|
+
}
|
|
26
|
+
/** One 64-byte block folded into the running state `h`. */
|
|
27
|
+
function compress(h, view, offset, w) {
|
|
28
|
+
for (let t = 0; t < 16; t += 1)
|
|
29
|
+
w[t] = view.getUint32(offset + t * 4);
|
|
30
|
+
for (let t = 16; t < 64; t += 1) {
|
|
31
|
+
const s0 = rotr(w[t - 15], 7) ^ rotr(w[t - 15], 18) ^ (w[t - 15] >>> 3);
|
|
32
|
+
const s1 = rotr(w[t - 2], 17) ^ rotr(w[t - 2], 19) ^ (w[t - 2] >>> 10);
|
|
33
|
+
w[t] = (w[t - 16] + s0 + w[t - 7] + s1) >>> 0;
|
|
34
|
+
}
|
|
35
|
+
let [a, b, c, d, e, f, g, hh] = h;
|
|
36
|
+
for (let t = 0; t < 64; t += 1) {
|
|
37
|
+
const t1 = (hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K[t] + w[t]) >>> 0;
|
|
38
|
+
const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0;
|
|
39
|
+
[hh, g, f, e, d, c, b, a] = [g, f, e, (d + t1) >>> 0, c, b, a, (t1 + t2) >>> 0];
|
|
40
|
+
}
|
|
41
|
+
[a, b, c, d, e, f, g, hh].forEach((value, index) => { h[index] = (h[index] + value) >>> 0; });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Lower-case hex SHA-256 of `required.text`'s UTF-8 encoding.
|
|
45
|
+
* @complexity O(text length).
|
|
46
|
+
*/
|
|
47
|
+
export function sha256Hex(required, _optional = {}) {
|
|
48
|
+
const h = Uint32Array.from([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]);
|
|
49
|
+
const view = pad(new TextEncoder().encode(required.text));
|
|
50
|
+
const w = new Uint32Array(64);
|
|
51
|
+
for (let offset = 0; offset < view.byteLength; offset += 64)
|
|
52
|
+
compress(h, view, offset, w);
|
|
53
|
+
return [...h].map(word => word.toString(16).padStart(8, '0')).join('');
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=digest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.js","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC;IACzB,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9I,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,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AC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The ONE writer of every search index (lot S3).
|
|
3
|
+
*
|
|
4
|
+
* Event path: a host domain event only NAMES a document; the indexer re-`load`s it from its source
|
|
5
|
+
* and writes the current truth (a document or a versioned tombstone) to every current target of the
|
|
6
|
+
* site — the active one and, during a rebuild or provider switch, the building one. Background path:
|
|
7
|
+
* `reconcile` settles indeterminate writes and retries failed ones (bounded), `backfill` scans every
|
|
8
|
+
* source into the building target behind a resumable watermark and flips it active with a CAS.
|
|
9
|
+
*
|
|
10
|
+
* Bookkeeping lives in the host's {@link SearchIndexStatePort}; the indexer is its only writer.
|
|
11
|
+
* Errors from host ports propagate so the caller's outbox/job retries; providers never throw by
|
|
12
|
+
* contract, and a provider that throws anyway is treated as an indeterminate (`unknown`) outcome.
|
|
13
|
+
*/
|
|
14
|
+
import { type ProviderRegistry } from '@jini-ai/core/provider-registry';
|
|
15
|
+
import { type SearchProvider, type SearchProviderContext } from './contract.js';
|
|
16
|
+
import type { SearchIndexer } from './api.js';
|
|
17
|
+
import type { SearchDocumentSource, SearchIndexStatePort, SearchTarget, SearchTargetPort } from './ports.js';
|
|
18
|
+
export interface SearchIndexerRequired {
|
|
19
|
+
readonly sources: readonly SearchDocumentSource[];
|
|
20
|
+
readonly registry: ProviderRegistry<SearchProvider>;
|
|
21
|
+
readonly targets: SearchTargetPort;
|
|
22
|
+
readonly state: SearchIndexStatePort;
|
|
23
|
+
resolveSiteId(required: {
|
|
24
|
+
readonly workspaceId: string;
|
|
25
|
+
}): Promise<string | null>;
|
|
26
|
+
contextFor(required: {
|
|
27
|
+
readonly target: SearchTarget;
|
|
28
|
+
readonly workspaceId: string;
|
|
29
|
+
}): Promise<SearchProviderContext | null>;
|
|
30
|
+
now(): number;
|
|
31
|
+
}
|
|
32
|
+
export interface SearchIndexerOptional {
|
|
33
|
+
/** Write attempts per key and revision before `reconcile` stops retrying a `failed` row. */
|
|
34
|
+
readonly maxAttempts?: number;
|
|
35
|
+
/** Records requested per `scan` page during backfill. */
|
|
36
|
+
readonly scanPageSize?: number;
|
|
37
|
+
}
|
|
38
|
+
/** The lastError recorded when a target's provider is not registered or has no context. */
|
|
39
|
+
export declare const SEARCH_NOT_CONFIGURED = "not_configured";
|
|
40
|
+
/**
|
|
41
|
+
* Build the single-writer indexer.
|
|
42
|
+
* @param required - Sources, provider registry and the host's target/state/site/context ports.
|
|
43
|
+
* @param optional.maxAttempts - Retry bound for `failed` rows (default 5).
|
|
44
|
+
* @param optional.scanPageSize - Backfill page size (default 100).
|
|
45
|
+
* @returns The {@link SearchIndexer} the composition root wires to its bus and background job.
|
|
46
|
+
* @complexity handleEvent O(targets · state lookups); reconcile O(limit) per target; backfill
|
|
47
|
+
* O(pageBudget · scanPageSize).
|
|
48
|
+
*/
|
|
49
|
+
export declare function createSearchIndexer(required: SearchIndexerRequired, optional?: SearchIndexerOptional): SearchIndexer;
|
|
50
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAmB,KAAK,gBAAgB,EAAuB,MAAM,iCAAiC,CAAC;AAC9G,OAAO,EAAwC,KAAK,cAAc,EA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