@dragon708/docmind-node 0.1.0-alpha.1

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.
@@ -0,0 +1,30 @@
1
+ import { DetectFileKindInput, AnalyzeOptions, AnalysisResult } from '@dragon708/docmind-core';
2
+ export { AnalysisAnalyzer, AnalysisResult, AnalyzeOptions, DetectFileKindInput, FileKind, FileKindMetadata, GenericAnalysisResult, TextAnalysisResult } from '@dragon708/docmind-core';
3
+ import { NamedInput } from '@dragon708/docmind-shared';
4
+
5
+ /**
6
+ * Inputs accepted by {@link analyzeFile} in this package.
7
+ * Paths and `file:` URLs are read with `fs`; other values pass through as core’s
8
+ * {@link DetectFileKindInput}.
9
+ */
10
+ type NodeAnalyzeInput = string | URL | DetectFileKindInput;
11
+ /**
12
+ * Reads a file from disk into a {@link NamedInput} suitable for `@dragon708/docmind-core`
13
+ * (binary `Buffer`, basename as `name` for extension / MIME hints).
14
+ */
15
+ declare function readFileToInput(path: string | URL): Promise<NamedInput<Buffer>>;
16
+ /** Wraps a `Buffer` as a named payload when you already know the filename. */
17
+ declare function bufferToInput(buffer: Buffer, name?: string): NamedInput<Buffer>;
18
+ /**
19
+ * Resolves paths / `file:` URLs to core’s internal shape; leaves other
20
+ * {@link DetectFileKindInput} values untouched.
21
+ */
22
+ declare function resolveNodeAnalyzeInput(input: NodeAnalyzeInput): Promise<DetectFileKindInput>;
23
+
24
+ /**
25
+ * Like `@dragon708/docmind-core`’s `analyzeFile`, but accepts filesystem paths and `file:` URLs
26
+ * in addition to buffers and browser-style inputs.
27
+ */
28
+ declare function analyzeFile(input: NodeAnalyzeInput, options?: AnalyzeOptions): Promise<AnalysisResult>;
29
+
30
+ export { type NodeAnalyzeInput, analyzeFile, bufferToInput, readFileToInput, resolveNodeAnalyzeInput };
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ import { analyzeFile as analyzeFile$1 } from '@dragon708/docmind-core';
2
+ import { readFile } from 'fs/promises';
3
+ import { basename } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ // src/analyze.ts
7
+ function toPathString(pathOrUrl) {
8
+ return pathOrUrl instanceof URL ? fileURLToPath(pathOrUrl) : pathOrUrl;
9
+ }
10
+ async function readFileToInput(path) {
11
+ const fsPath = toPathString(path);
12
+ const data = await readFile(fsPath);
13
+ return {
14
+ data,
15
+ name: basename(fsPath)
16
+ };
17
+ }
18
+ function bufferToInput(buffer, name) {
19
+ return name !== void 0 ? { data: buffer, name } : { data: buffer };
20
+ }
21
+ async function resolveNodeAnalyzeInput(input) {
22
+ if (typeof input === "string" || input instanceof URL) {
23
+ return readFileToInput(input);
24
+ }
25
+ return input;
26
+ }
27
+
28
+ // src/analyze.ts
29
+ async function analyzeFile(input, options) {
30
+ const resolved = await resolveNodeAnalyzeInput(input);
31
+ return analyzeFile$1(resolved, options);
32
+ }
33
+
34
+ export { analyzeFile, bufferToInput, readFileToInput, resolveNodeAnalyzeInput };
35
+ //# sourceMappingURL=index.js.map
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toCoreInput.ts","../src/analyze.ts"],"names":["analyzeWithCore"],"mappings":";;;;;;AAaA,SAAS,aAAa,SAAA,EAAiC;AACrD,EAAA,OAAO,SAAA,YAAqB,GAAA,GAAM,aAAA,CAAc,SAAS,CAAA,GAAI,SAAA;AAC/D;AAMA,eAAsB,gBAAgB,IAAA,EAAiD;AACrF,EAAA,MAAM,MAAA,GAAS,aAAa,IAAI,CAAA;AAChC,EAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,MAAM,CAAA;AAClC,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,IAAA,EAAM,SAAS,MAAM;AAAA,GACvB;AACF;AAGO,SAAS,aAAA,CAAc,QAAgB,IAAA,EAAmC;AAC/E,EAAA,OAAO,IAAA,KAAS,SAAY,EAAE,IAAA,EAAM,QAAQ,IAAA,EAAK,GAAI,EAAE,IAAA,EAAM,MAAA,EAAO;AACtE;AAMA,eAAsB,wBAAwB,KAAA,EAAuD;AACnG,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,YAAiB,GAAA,EAAK;AACrD,IAAA,OAAO,gBAAgB,KAAK,CAAA;AAAA,EAC9B;AACA,EAAA,OAAO,KAAA;AACT;;;ACpCA,eAAsB,WAAA,CACpB,OACA,OAAA,EACyB;AACzB,EAAA,MAAM,QAAA,GAAW,MAAM,uBAAA,CAAwB,KAAK,CAAA;AACpD,EAAA,OAAOA,aAAA,CAAgB,UAAU,OAAO,CAAA;AAC1C","file":"index.js","sourcesContent":["import type { DetectFileKindInput } from \"@dragon708/docmind-core\";\nimport type { NamedInput } from \"@dragon708/docmind-shared\";\nimport { readFile } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Inputs accepted by {@link analyzeFile} in this package.\n * Paths and `file:` URLs are read with `fs`; other values pass through as core’s\n * {@link DetectFileKindInput}.\n */\nexport type NodeAnalyzeInput = string | URL | DetectFileKindInput;\n\nfunction toPathString(pathOrUrl: string | URL): string {\n return pathOrUrl instanceof URL ? fileURLToPath(pathOrUrl) : pathOrUrl;\n}\n\n/**\n * Reads a file from disk into a {@link NamedInput} suitable for `@dragon708/docmind-core`\n * (binary `Buffer`, basename as `name` for extension / MIME hints).\n */\nexport async function readFileToInput(path: string | URL): Promise<NamedInput<Buffer>> {\n const fsPath = toPathString(path);\n const data = await readFile(fsPath);\n return {\n data,\n name: basename(fsPath),\n };\n}\n\n/** Wraps a `Buffer` as a named payload when you already know the filename. */\nexport function bufferToInput(buffer: Buffer, name?: string): NamedInput<Buffer> {\n return name !== undefined ? { data: buffer, name } : { data: buffer };\n}\n\n/**\n * Resolves paths / `file:` URLs to core’s internal shape; leaves other\n * {@link DetectFileKindInput} values untouched.\n */\nexport async function resolveNodeAnalyzeInput(input: NodeAnalyzeInput): Promise<DetectFileKindInput> {\n if (typeof input === \"string\" || input instanceof URL) {\n return readFileToInput(input);\n }\n return input;\n}\n","import { analyzeFile as analyzeWithCore } from \"@dragon708/docmind-core\";\nimport type { AnalyzeOptions, AnalysisResult } from \"@dragon708/docmind-core\";\nimport { resolveNodeAnalyzeInput, type NodeAnalyzeInput } from \"./toCoreInput.js\";\n\n/**\n * Like `@dragon708/docmind-core`’s `analyzeFile`, but accepts filesystem paths and `file:` URLs\n * in addition to buffers and browser-style inputs.\n */\nexport async function analyzeFile(\n input: NodeAnalyzeInput,\n options?: AnalyzeOptions,\n): Promise<AnalysisResult> {\n const resolved = await resolveNodeAnalyzeInput(input);\n return analyzeWithCore(resolved, options);\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@dragon708/docmind-node",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Node.js file I/O helpers and core integration for DocMind (does not run in browsers).",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "dev": "tsup --watch",
25
+ "test": "vitest run",
26
+ "clean": "node -e \"try{require('fs').rmSync('dist',{recursive:true,force:true})}catch(e){}\""
27
+ },
28
+ "keywords": [
29
+ "docmind",
30
+ "node"
31
+ ],
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@dragon708/docmind-core": "^0.1.0-alpha.1",
35
+ "@dragon708/docmind-shared": "^0.1.0-alpha.1"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^20.19.37",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "engines": {
43
+ "node": ">=18"
44
+ }
45
+ }