@markitdownjs/next 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/dist/api-route.d.ts +8 -0
- package/dist/api-route.d.ts.map +1 -0
- package/dist/api-route.js +29 -0
- package/dist/api-route.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/route-handler.d.ts +4 -0
- package/dist/route-handler.d.ts.map +1 -0
- package/dist/route-handler.js +50 -0
- package/dist/route-handler.js.map +1 -0
- package/dist/server-action.d.ts +3 -0
- package/dist/server-action.d.ts.map +1 -0
- package/dist/server-action.js +11 -0
- package/dist/server-action.js.map +1 -0
- package/dist/upload.d.ts +11 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +29 -0
- package/dist/upload.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface CreateConvertRouteOptions {
|
|
2
|
+
maxFileSize?: number;
|
|
3
|
+
allowedTypes?: string[];
|
|
4
|
+
onConvert?: (result: unknown) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function createConvertRoute(options?: CreateConvertRouteOptions): (request: Request) => Promise<Response>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=api-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-route.d.ts","sourceRoot":"","sources":["../src/api-route.ts"],"names":[],"mappings":"AAEA,UAAU,yBAAyB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,IAC7C,SAAS,OAAO,uBAgC5C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function createConvertRoute(options = {}) {
|
|
2
|
+
return async function POST(request) {
|
|
3
|
+
try {
|
|
4
|
+
const formData = await request.formData();
|
|
5
|
+
const file = formData.get('file');
|
|
6
|
+
if (!file) {
|
|
7
|
+
return Response.json({ error: 'No file provided' }, { status: 400 });
|
|
8
|
+
}
|
|
9
|
+
if (options.maxFileSize && file.size > options.maxFileSize) {
|
|
10
|
+
return Response.json({ error: 'File too large' }, { status: 413 });
|
|
11
|
+
}
|
|
12
|
+
if (options.allowedTypes && options.allowedTypes.length > 0) {
|
|
13
|
+
const ext = file.name.split('.').pop()?.toLowerCase();
|
|
14
|
+
if (!ext || !options.allowedTypes.includes(ext)) {
|
|
15
|
+
return Response.json({ error: 'File type not allowed' }, { status: 415 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const { MarkItDown } = await import('@markitdownjs/core');
|
|
19
|
+
const parser = new MarkItDown();
|
|
20
|
+
const result = await parser.convert(file);
|
|
21
|
+
options.onConvert?.(result);
|
|
22
|
+
return Response.json(result);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return Response.json({ error: error instanceof Error ? error.message : 'Conversion failed' }, { status: 500 });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=api-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-route.js","sourceRoot":"","sources":["../src/api-route.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IACxE,OAAO,KAAK,UAAU,IAAI,CAAC,OAAgB;QACzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC;YAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,QAAQ,CAAC,IAAI,CAAC,E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CAAC,mBAAmB,EAAE,EACvE,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createConvertRoute } from './api-route.js';
|
|
2
|
+
export { convertDocumentAction } from './server-action.js';
|
|
3
|
+
export { formatsRoute, convertRoute, batchRoute } from './route-handler.js';
|
|
4
|
+
export { handleFileUpload, validateFile } from './upload.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createConvertRoute } from './api-route.js';
|
|
2
|
+
export { convertDocumentAction } from './server-action.js';
|
|
3
|
+
export { formatsRoute, convertRoute, batchRoute } from './route-handler.js';
|
|
4
|
+
export { handleFileUpload, validateFile } from './upload.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-handler.d.ts","sourceRoot":"","sources":["../src/route-handler.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,sBAIjC;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,qBAmBlD;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,qBAsChD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getSupportedExtensions, getSupportedMimeTypes } from '@markitdownjs/shared';
|
|
2
|
+
export async function formatsRoute() {
|
|
3
|
+
const extensions = getSupportedExtensions();
|
|
4
|
+
const mimeTypes = getSupportedMimeTypes();
|
|
5
|
+
return Response.json({ extensions, mimeTypes });
|
|
6
|
+
}
|
|
7
|
+
export async function convertRoute(request) {
|
|
8
|
+
try {
|
|
9
|
+
const formData = await request.formData();
|
|
10
|
+
const file = formData.get('file');
|
|
11
|
+
if (!file) {
|
|
12
|
+
return Response.json({ error: 'No file provided' }, { status: 400 });
|
|
13
|
+
}
|
|
14
|
+
const { MarkItDown } = await import('@markitdownjs/core');
|
|
15
|
+
const parser = new MarkItDown();
|
|
16
|
+
const result = await parser.convert(file);
|
|
17
|
+
return Response.json(result);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return Response.json({ error: error instanceof Error ? error.message : 'Conversion failed' }, { status: 500 });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function batchRoute(request) {
|
|
24
|
+
try {
|
|
25
|
+
const formData = await request.formData();
|
|
26
|
+
const entries = Array.from(formData.entries());
|
|
27
|
+
const files = entries
|
|
28
|
+
.filter((entry) => entry[1] instanceof File);
|
|
29
|
+
if (files.length === 0) {
|
|
30
|
+
return Response.json({ error: 'No files provided' }, { status: 400 });
|
|
31
|
+
}
|
|
32
|
+
const { MarkItDown } = await import('@markitdownjs/core');
|
|
33
|
+
const parser = new MarkItDown();
|
|
34
|
+
const results = await Promise.allSettled(files.map(async ([name, file]) => {
|
|
35
|
+
const result = await parser.convert(file);
|
|
36
|
+
return { name, result };
|
|
37
|
+
}));
|
|
38
|
+
const succeeded = results
|
|
39
|
+
.filter((r) => r.status === 'fulfilled')
|
|
40
|
+
.map((r) => r.value);
|
|
41
|
+
const failed = results
|
|
42
|
+
.filter((r) => r.status === 'rejected')
|
|
43
|
+
.map((r, i) => ({ name: files[i][0], error: r.reason?.message ?? 'Conversion failed' }));
|
|
44
|
+
return Response.json({ succeeded, failed });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return Response.json({ error: error instanceof Error ? error.message : 'Batch conversion failed' }, { status: 500 });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=route-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-handler.js","sourceRoot":"","sources":["../src/route-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAErF,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,UAAU,GAAG,sBAAsB,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,qBAAqB,EAAE,CAAC;IAC1C,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,C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AE,MAAM,sBAAsB,CAAC;AAE7D,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAUzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
export async function convertDocumentAction(formData) {
|
|
3
|
+
const file = formData.get('file');
|
|
4
|
+
if (!file) {
|
|
5
|
+
throw new Error('No file provided');
|
|
6
|
+
}
|
|
7
|
+
const { MarkItDown } = await import('@markitdownjs/core');
|
|
8
|
+
const parser = new MarkItDown();
|
|
9
|
+
return parser.convert(file);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=server-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-action.js","sourceRoot":"","sources":["../src/server-action.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAkB;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC;IAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ValidateFileOptions {
|
|
2
|
+
maxFileSize?: number;
|
|
3
|
+
allowedTypes?: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare function handleFileUpload(request: Request): Promise<File>;
|
|
6
|
+
export declare function validateFile(file: File, options?: ValidateFileOptions): {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBtE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,mBAAwB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAc9G"}
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export async function handleFileUpload(request) {
|
|
2
|
+
const contentType = request.headers.get('content-type') ?? '';
|
|
3
|
+
if (contentType.includes('multipart/form-data')) {
|
|
4
|
+
const formData = await request.formData();
|
|
5
|
+
const file = formData.get('file');
|
|
6
|
+
if (!file) {
|
|
7
|
+
throw new Error('No file provided in form data');
|
|
8
|
+
}
|
|
9
|
+
return file;
|
|
10
|
+
}
|
|
11
|
+
const body = await request.arrayBuffer();
|
|
12
|
+
const fileName = request.headers.get('x-file-name') ?? 'unknown';
|
|
13
|
+
const mimeType = request.headers.get('content-type') ?? 'application/octet-stream';
|
|
14
|
+
return new File([body], fileName, { type: mimeType });
|
|
15
|
+
}
|
|
16
|
+
export function validateFile(file, options = {}) {
|
|
17
|
+
if (options.maxFileSize && file.size > options.maxFileSize) {
|
|
18
|
+
const maxMB = Math.round(options.maxFileSize / (1024 * 1024));
|
|
19
|
+
return { valid: false, error: `File size exceeds ${maxMB}MB limit` };
|
|
20
|
+
}
|
|
21
|
+
if (options.allowedTypes && options.allowedTypes.length > 0) {
|
|
22
|
+
const ext = file.name.split('.').pop()?.toLowerCase();
|
|
23
|
+
if (!ext || !options.allowedTypes.includes(ext)) {
|
|
24
|
+
return { valid: false, error: `File type .${ext ?? '?'} is not allowed` };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { valid: true };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgB;IACrD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAE9D,IAAI,WAAW,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC;QACjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC;IACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,0BAA0B,CAAC;IACnF,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,UAA+B,EAAE;IACxE,IAAI,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;QAC9D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,KAAK,UAAU,EAAE,CAAC;IACvE,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC;QACtD,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,iBAAiB,EAAE,CAAC;QAC5E,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@markitdownjs/next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js integration for MarkItDownJS document conversion",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@markitdownjs/shared": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"next": ">=14.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typescript": "^5.5.0",
|
|
27
|
+
"next": "^14.0.0",
|
|
28
|
+
"@markitdownjs/core": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc --project tsconfig.json",
|
|
32
|
+
"dev": "tsc --watch --project tsconfig.json",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
35
|
+
}
|
|
36
|
+
}
|