@digipair/skill-markitdown 0.57.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/index.cjs.d.ts +1 -0
- package/index.cjs.js +40 -0
- package/index.d.ts +1 -0
- package/index.esm.js +36 -0
- package/libs/skill-markitdown/src/index.d.ts +1 -0
- package/libs/skill-markitdown/src/lib/skill-markitdown.d.ts +2 -0
- package/package.json +7 -0
- package/schema.fr.json +889 -0
- package/schema.json +889 -0
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var child_process = require('child_process');
|
|
6
|
+
|
|
7
|
+
let MaikitdownService = class MaikitdownService {
|
|
8
|
+
async convert(params, _pinsSettingsList, context) {
|
|
9
|
+
var _context_privates;
|
|
10
|
+
var _context_privates_MARKITDOWN_PATH, _ref;
|
|
11
|
+
const { file, path = (_ref = (_context_privates_MARKITDOWN_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.MARKITDOWN_PATH) != null ? _context_privates_MARKITDOWN_PATH : process.env['MARKITDOWN_PATH']) != null ? _ref : 'markitdown' } = params;
|
|
12
|
+
return new Promise((resolve, reject)=>{
|
|
13
|
+
// Spawn the markitdown process
|
|
14
|
+
const markitdown = child_process.spawn(path);
|
|
15
|
+
let markdown = '';
|
|
16
|
+
let errorOutput = '';
|
|
17
|
+
// Listen for data from the stdout stream
|
|
18
|
+
markitdown.stdout.on('data', (data)=>{
|
|
19
|
+
markdown += data.toString();
|
|
20
|
+
});
|
|
21
|
+
// Listen for data from the stderr stream
|
|
22
|
+
markitdown.stderr.on('data', (data)=>{
|
|
23
|
+
errorOutput += data.toString();
|
|
24
|
+
});
|
|
25
|
+
// Handle the close event
|
|
26
|
+
markitdown.on('close', (code)=>{
|
|
27
|
+
if (code !== 0) {
|
|
28
|
+
return reject(new Error(`markitdown process exited with code ${code}: ${errorOutput}`));
|
|
29
|
+
}
|
|
30
|
+
resolve(markdown);
|
|
31
|
+
});
|
|
32
|
+
// Write the decoded PDF content to stdin
|
|
33
|
+
markitdown.stdin.write(Buffer.from(file.replace(/^data:.*;base64,/, ''), 'base64'));
|
|
34
|
+
markitdown.stdin.end();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const convert = (params, pinsSettingsList, context)=>new MaikitdownService().convert(params, pinsSettingsList, context);
|
|
39
|
+
|
|
40
|
+
exports.convert = convert;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './libs/skill-markitdown/src/index';
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
3
|
+
let MaikitdownService = class MaikitdownService {
|
|
4
|
+
async convert(params, _pinsSettingsList, context) {
|
|
5
|
+
var _context_privates;
|
|
6
|
+
var _context_privates_MARKITDOWN_PATH, _ref;
|
|
7
|
+
const { file, path = (_ref = (_context_privates_MARKITDOWN_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.MARKITDOWN_PATH) != null ? _context_privates_MARKITDOWN_PATH : process.env['MARKITDOWN_PATH']) != null ? _ref : 'markitdown' } = params;
|
|
8
|
+
return new Promise((resolve, reject)=>{
|
|
9
|
+
// Spawn the markitdown process
|
|
10
|
+
const markitdown = spawn(path);
|
|
11
|
+
let markdown = '';
|
|
12
|
+
let errorOutput = '';
|
|
13
|
+
// Listen for data from the stdout stream
|
|
14
|
+
markitdown.stdout.on('data', (data)=>{
|
|
15
|
+
markdown += data.toString();
|
|
16
|
+
});
|
|
17
|
+
// Listen for data from the stderr stream
|
|
18
|
+
markitdown.stderr.on('data', (data)=>{
|
|
19
|
+
errorOutput += data.toString();
|
|
20
|
+
});
|
|
21
|
+
// Handle the close event
|
|
22
|
+
markitdown.on('close', (code)=>{
|
|
23
|
+
if (code !== 0) {
|
|
24
|
+
return reject(new Error(`markitdown process exited with code ${code}: ${errorOutput}`));
|
|
25
|
+
}
|
|
26
|
+
resolve(markdown);
|
|
27
|
+
});
|
|
28
|
+
// Write the decoded PDF content to stdin
|
|
29
|
+
markitdown.stdin.write(Buffer.from(file.replace(/^data:.*;base64,/, ''), 'base64'));
|
|
30
|
+
markitdown.stdin.end();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const convert = (params, pinsSettingsList, context)=>new MaikitdownService().convert(params, pinsSettingsList, context);
|
|
35
|
+
|
|
36
|
+
export { convert };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/skill-markitdown';
|