New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cboulanger/abbyy-cloud-ocr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cboulanger/abbyy-cloud-ocr - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

src/ocrsdk.js

3

package.json
{
"name": "@cboulanger/abbyy-cloud-ocr",
"version": "2.0.0",
"version": "2.0.1",
"description": "NodeJS client and CLI to interact with the ABBYY Cloud OCR service ",

@@ -25,2 +25,3 @@ "main": "src/index.js",

"src/index.d.ts",
"src/ocrsdk.js",
"package.json",

@@ -27,0 +28,0 @@ "tsconfig.json",

@@ -71,1 +71,23 @@ # Abbyy Cloud OCR client

before calling the executable (or provide them on the command line).
The executable lets you do something like this:
````bash
# export credentials so that you don't need to provide them as CLI options
export ABBYY_SERVICE_URL=XXXX
export ABBYY_APP_ID=YYYYYY
export ABBYY_APP_PASSWD=ZZZZZ
PAGES_BEFORE=$(abbyy-cloud-ocr info | jq ".pages")
abbyy-cloud-ocr process \
-l German \
-e docx,txtUnstructured \
-c "txtUnstructured:paragraphAsOneLine=true" \
-o ~/files/OCR \
~/files/PDF-SOURCE/*
PAGES_AFTER=$(abbyy-cloud-ocr info | jq ".pages")
echo "$(expr $PAGES_BEFORE - $PAGES_AFTER) pages used, $PAGES_AFTER left."
````

@@ -52,2 +52,9 @@ "use strict";

(function () { return __awaiter(void 0, void 0, void 0, function () {
// authentication options
function addAuthOptions(command) {
command
.option("-u, --service-url <url>", "The http endpoint of the Cloud OCR Service")
.option("-i, --app-id <id>", "The id of the application")
.option("-P, --password <password>", "The application password");
}
/**

@@ -71,5 +78,5 @@ * Sets up and returns the OCR client

function processFiles(files, options) {
var e_1, _a;
var e_2, _a;
return __awaiter(this, void 0, void 0, function () {
var ocr, settings, _i, files_1, filePath, _b, _c, processedFilePath, e_1_1;
var ocr, settings, _i, files_1, filePath, _b, _c, processedFilePath, e_2_1;
return __generator(this, function (_d) {

@@ -85,3 +92,3 @@ switch (_d.label) {

filePath = files_1[_i];
options.filenames || console.log("Processing " + filePath);
options.quiet || options.filenames || console.log("Processing " + filePath);
return [4 /*yield*/, ocr.process(filePath, settings)];

@@ -93,3 +100,3 @@ case 2:

_d.trys.push([3, 8, 9, 14]);
_b = (e_1 = void 0, __asyncValues(ocr.downloadResult(options.outputPath)));
_b = (e_2 = void 0, __asyncValues(ocr.downloadResult(options.outputPath)));
_d.label = 4;

@@ -100,3 +107,3 @@ case 4: return [4 /*yield*/, _b.next()];

processedFilePath = _c.value;
console.info((options.filenames ? "" : "Downloaded ") + processedFilePath);
options.quiet || console.info((options.filenames ? "" : "Downloaded ") + processedFilePath);
_d.label = 6;

@@ -106,4 +113,4 @@ case 6: return [3 /*break*/, 4];

case 8:
e_1_1 = _d.sent();
e_1 = { error: e_1_1 };
e_2_1 = _d.sent();
e_2 = { error: e_2_1 };
return [3 /*break*/, 14];

@@ -119,3 +126,3 @@ case 9:

case 12:
if (e_1) throw e_1.error;
if (e_2) throw e_2.error;
return [7 /*endfinally*/];

@@ -178,2 +185,3 @@ case 13: return [7 /*endfinally*/];

}
var e_1;
return __generator(this, function (_a) {

@@ -183,3 +191,3 @@ switch (_a.label) {

// process
commander_1.program
addAuthOptions(commander_1.program
.command("process <files...>")

@@ -192,5 +200,6 @@ .description("Process the given files and download the results")

.option("-F, --filenames", "Output the filenames of the processed and downloaded files")
.action(processFiles);
.option("-q, --quiet", "No messages or visual feedback except errors")
.action(processFiles));
// list
commander_1.program
addAuthOptions(commander_1.program
.command("list")

@@ -200,16 +209,21 @@ .description("List ongoing or finished tasks.")

.option("-f, --finished", "Only list finished tasks")
.action(list);
.action(list));
// info
commander_1.program.command("info").action(info);
// general options
commander_1.program
.option("-u, --service-url <url>", "The http endpoint of the Cloud OCR Service")
.option("-i, --app-id <id>", "The id of the application")
.option("-P, --password <password>", "The application password");
// parse and start caommand!
addAuthOptions(commander_1.program.command("info").action(info));
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, commander_1.program.parseAsync()];
case 1:
// parse and start caommand!
case 2:
_a.sent();
return [2 /*return*/];
return [3 /*break*/, 4];
case 3:
e_1 = _a.sent();
if (e_1.message.match(/^[0-9]{3} /) || typeof e_1.details != "undefined") {
// HTTP Error Response or Abbyy Error Response
console.error(e_1.message);
process.exit(1);
}
throw e_1;
case 4: return [2 /*return*/];
}

@@ -216,0 +230,0 @@ });

import {AbbyyOcr, ProcessingSettings} from './src/index';
import {program} from 'commander';
import {Command, program} from 'commander';

@@ -20,7 +20,16 @@ const process = require('process');

finished?: boolean,
summary?: boolean
summary?: boolean,
quiet?:boolean
};
// authentication options
function addAuthOptions(command: typeof program) {
command
.option("-u, --service-url <url>", "The http endpoint of the Cloud OCR Service")
.option("-i, --app-id <id>", "The id of the application")
.option("-P, --password <password>", "The application password");
}
// process
program
addAuthOptions(program
.command("process <files...>")

@@ -33,6 +42,7 @@ .description("Process the given files and download the results")

.option("-F, --filenames", "Output the filenames of the processed and downloaded files")
.action(processFiles);
.option("-q, --quiet", "No messages or visual feedback except errors")
.action(processFiles));
// list
program
addAuthOptions(program
.command("list")

@@ -42,16 +52,18 @@ .description("List ongoing or finished tasks.")

.option("-f, --finished", "Only list finished tasks")
.action(list);
.action(list));
// info
program.command("info").action(info)
addAuthOptions(program.command("info").action(info));
// general options
program
.option("-u, --service-url <url>", "The http endpoint of the Cloud OCR Service")
.option("-i, --app-id <id>", "The id of the application")
.option("-P, --password <password>", "The application password")
try {
await program.parseAsync();
} catch (e) {
if (e.message.match(/^[0-9]{3} /) || typeof e.details != "undefined" ) {
// HTTP Error Response or Abbyy Error Response
console.error(e.message);
process.exit(1);
}
throw e;
}
// parse and start caommand!
await program.parseAsync();
/**

@@ -79,6 +91,6 @@ * Sets up and returns the OCR client

for (let filePath of files) {
options.filenames || console.log("Processing " + filePath);
options.quiet || options.filenames || console.log("Processing " + filePath);
await ocr.process(filePath, settings);
for await (const processedFilePath of ocr.downloadResult(options.outputPath) ) {
console.info( (options.filenames ? "" : "Downloaded ") + processedFilePath);
options.quiet || console.info( (options.filenames ? "" : "Downloaded ") + processedFilePath);
}

@@ -85,0 +97,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc