@mdfn/searchfn 0.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/README.md +3 -0
- package/dist/index.cjs +43 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/package.json +8 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MDFN_SEARCHFN_VERSION: () => MDFN_SEARCHFN_VERSION,
|
|
24
|
+
createSearchRecords: () => createSearchRecords
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_render = require("@mdfn/render");
|
|
28
|
+
function createSearchRecords(documentId, document, maxChunkLength = 1600) {
|
|
29
|
+
const extracted = (0, import_render.extractDocument)(document, { maxChunkLength });
|
|
30
|
+
const links = extracted.links.map((link) => link.url);
|
|
31
|
+
const namespace = `${documentId.length}:${documentId}`;
|
|
32
|
+
return [
|
|
33
|
+
{ id: `document:${namespace}`, documentId, kind: "document", ordinal: 0, text: extracted.plainText, headings: extracted.headings.map((heading) => heading.text), links },
|
|
34
|
+
...extracted.chunks.map((chunk, index) => ({ id: `chunk:${namespace}:${index}`, documentId, kind: "chunk", ordinal: index, text: chunk.text, headings: chunk.headingPath, links: chunk.links.map((link) => link.url) }))
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
var MDFN_SEARCHFN_VERSION = "0.1.0";
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
MDFN_SEARCHFN_VERSION,
|
|
41
|
+
createSearchRecords
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { MdfnDocument } from \"@mdfn/core\";\nimport { extractDocument } from \"@mdfn/render\";\n\nexport interface MdfnSearchRecord {\n readonly id: string;\n readonly documentId: string;\n readonly kind: \"document\" | \"chunk\";\n readonly ordinal: number;\n readonly text: string;\n readonly headings: readonly string[];\n readonly links: readonly string[];\n}\n\nexport function createSearchRecords(documentId: string, document: MdfnDocument, maxChunkLength = 1600): readonly MdfnSearchRecord[] {\n const extracted = extractDocument(document, { maxChunkLength });\n const links = extracted.links.map((link) => link.url);\n const namespace = `${documentId.length}:${documentId}`;\n return [\n { id: `document:${namespace}`, documentId, kind: \"document\", ordinal: 0, text: extracted.plainText, headings: extracted.headings.map((heading) => heading.text), links },\n ...extracted.chunks.map((chunk, index) => ({ id: `chunk:${namespace}:${index}`, documentId, kind: \"chunk\" as const, ordinal: index, text: chunk.text, headings: chunk.headingPath, links: chunk.links.map((link) => link.url) })),\n ];\n}\n\nexport const MDFN_SEARCHFN_VERSION = \"0.1.0\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAgC;AAYzB,SAAS,oBAAoB,YAAoB,UAAwB,iBAAiB,MAAmC;AAClI,QAAM,gBAAY,+BAAgB,UAAU,EAAE,eAAe,CAAC;AAC9D,QAAM,QAAQ,UAAU,MAAM,IAAI,CAAC,SAAS,KAAK,GAAG;AACpD,QAAM,YAAY,GAAG,WAAW,MAAM,IAAI,UAAU;AACpD,SAAO;AAAA,IACL,EAAE,IAAI,YAAY,SAAS,IAAI,YAAY,MAAM,YAAY,SAAS,GAAG,MAAM,UAAU,WAAW,UAAU,UAAU,SAAS,IAAI,CAAC,YAAY,QAAQ,IAAI,GAAG,MAAM;AAAA,IACvK,GAAG,UAAU,OAAO,IAAI,CAAC,OAAO,WAAW,EAAE,IAAI,SAAS,SAAS,IAAI,KAAK,IAAI,YAAY,MAAM,SAAkB,SAAS,OAAO,MAAM,MAAM,MAAM,UAAU,MAAM,aAAa,OAAO,MAAM,MAAM,IAAI,CAAC,SAAS,KAAK,GAAG,EAAE,EAAE;AAAA,EAClO;AACF;AAEO,IAAM,wBAAwB;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MdfnDocument } from '@mdfn/core';
|
|
2
|
+
|
|
3
|
+
interface MdfnSearchRecord {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly documentId: string;
|
|
6
|
+
readonly kind: "document" | "chunk";
|
|
7
|
+
readonly ordinal: number;
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly headings: readonly string[];
|
|
10
|
+
readonly links: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
declare function createSearchRecords(documentId: string, document: MdfnDocument, maxChunkLength?: number): readonly MdfnSearchRecord[];
|
|
13
|
+
declare const MDFN_SEARCHFN_VERSION: "0.1.0";
|
|
14
|
+
|
|
15
|
+
export { MDFN_SEARCHFN_VERSION, type MdfnSearchRecord, createSearchRecords };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MdfnDocument } from '@mdfn/core';
|
|
2
|
+
|
|
3
|
+
interface MdfnSearchRecord {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly documentId: string;
|
|
6
|
+
readonly kind: "document" | "chunk";
|
|
7
|
+
readonly ordinal: number;
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly headings: readonly string[];
|
|
10
|
+
readonly links: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
declare function createSearchRecords(documentId: string, document: MdfnDocument, maxChunkLength?: number): readonly MdfnSearchRecord[];
|
|
13
|
+
declare const MDFN_SEARCHFN_VERSION: "0.1.0";
|
|
14
|
+
|
|
15
|
+
export { MDFN_SEARCHFN_VERSION, type MdfnSearchRecord, createSearchRecords };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { extractDocument } from "@mdfn/render";
|
|
3
|
+
function createSearchRecords(documentId, document, maxChunkLength = 1600) {
|
|
4
|
+
const extracted = extractDocument(document, { maxChunkLength });
|
|
5
|
+
const links = extracted.links.map((link) => link.url);
|
|
6
|
+
const namespace = `${documentId.length}:${documentId}`;
|
|
7
|
+
return [
|
|
8
|
+
{ id: `document:${namespace}`, documentId, kind: "document", ordinal: 0, text: extracted.plainText, headings: extracted.headings.map((heading) => heading.text), links },
|
|
9
|
+
...extracted.chunks.map((chunk, index) => ({ id: `chunk:${namespace}:${index}`, documentId, kind: "chunk", ordinal: index, text: chunk.text, headings: chunk.headingPath, links: chunk.links.map((link) => link.url) }))
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
var MDFN_SEARCHFN_VERSION = "0.1.0";
|
|
13
|
+
export {
|
|
14
|
+
MDFN_SEARCHFN_VERSION,
|
|
15
|
+
createSearchRecords
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { MdfnDocument } from \"@mdfn/core\";\nimport { extractDocument } from \"@mdfn/render\";\n\nexport interface MdfnSearchRecord {\n readonly id: string;\n readonly documentId: string;\n readonly kind: \"document\" | \"chunk\";\n readonly ordinal: number;\n readonly text: string;\n readonly headings: readonly string[];\n readonly links: readonly string[];\n}\n\nexport function createSearchRecords(documentId: string, document: MdfnDocument, maxChunkLength = 1600): readonly MdfnSearchRecord[] {\n const extracted = extractDocument(document, { maxChunkLength });\n const links = extracted.links.map((link) => link.url);\n const namespace = `${documentId.length}:${documentId}`;\n return [\n { id: `document:${namespace}`, documentId, kind: \"document\", ordinal: 0, text: extracted.plainText, headings: extracted.headings.map((heading) => heading.text), links },\n ...extracted.chunks.map((chunk, index) => ({ id: `chunk:${namespace}:${index}`, documentId, kind: \"chunk\" as const, ordinal: index, text: chunk.text, headings: chunk.headingPath, links: chunk.links.map((link) => link.url) })),\n ];\n}\n\nexport const MDFN_SEARCHFN_VERSION = \"0.1.0\" as const;\n"],"mappings":";AACA,SAAS,uBAAuB;AAYzB,SAAS,oBAAoB,YAAoB,UAAwB,iBAAiB,MAAmC;AAClI,QAAM,YAAY,gBAAgB,UAAU,EAAE,eAAe,CAAC;AAC9D,QAAM,QAAQ,UAAU,MAAM,IAAI,CAAC,SAAS,KAAK,GAAG;AACpD,QAAM,YAAY,GAAG,WAAW,MAAM,IAAI,UAAU;AACpD,SAAO;AAAA,IACL,EAAE,IAAI,YAAY,SAAS,IAAI,YAAY,MAAM,YAAY,SAAS,GAAG,MAAM,UAAU,WAAW,UAAU,UAAU,SAAS,IAAI,CAAC,YAAY,QAAQ,IAAI,GAAG,MAAM;AAAA,IACvK,GAAG,UAAU,OAAO,IAAI,CAAC,OAAO,WAAW,EAAE,IAAI,SAAS,SAAS,IAAI,KAAK,IAAI,YAAY,MAAM,SAAkB,SAAS,OAAO,MAAM,MAAM,MAAM,UAAU,MAAM,aAAa,OAAO,MAAM,MAAM,IAAI,CAAC,SAAS,KAAK,GAAG,EAAE,EAAE;AAAA,EAClO;AACF;AAEO,IAAM,wBAAwB;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mdfn/searchfn", "version": "0.1.0", "description": "Deterministic search extraction records for mdfn documents", "type": "module",
|
|
3
|
+
"main": "dist/index.cjs", "module": "dist/index.js", "types": "dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } },
|
|
4
|
+
"scripts": { "build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean", "test": "vitest run", "typecheck": "tsc --noEmit -p tsconfig.json", "lint": "tsc --noEmit -p tsconfig.json", "prepack": "npm run build" },
|
|
5
|
+
"dependencies": { "@mdfn/core": "0.1.0", "@mdfn/render": "0.1.0" }, "devDependencies": { "@mdfn/markdown": "0.1.0", "tsup": "^8.0.0", "typescript": "^5.3.0", "vitest": "3.2.4" },
|
|
6
|
+
"files": ["dist", "README.md"], "sideEffects": false, "license": "MIT", "engines": { "node": ">=20 <25" }, "repository": { "type": "git", "url": "git+https://github.com/21nCo/super-functions.git", "directory": "mdfn/searchfn" }, "publishConfig": { "access": "public" },
|
|
7
|
+
"mdfn": { "status": "optional", "layer": "bridge", "schemaVersion": 1 }
|
|
8
|
+
}
|