Socket
Socket
Sign inDemoInstall

mindee

Package Overview
Dependencies
Maintainers
7
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mindee - npm Package Compare versions

Comparing version 4.9.0 to 4.9.1

src/errors/mindeeError.d.ts

8

CHANGELOG.md
# CHANGELOG
## v4.9.1 - 2024-03-05
### Changes
* :recycle: update error handling to account for future evolutions
* :recycle: expose the input, geometry & imageOperations modules in internals for better fine-tuning
* :recycle: fix inconsistencies with naming conventions
* :memo: add missing reference documentation
## v4.9.0 - 2024-02-21

@@ -4,0 +12,0 @@ ### Changes

2

package.json
{
"name": "mindee",
"version": "4.9.0",
"version": "4.9.1",
"description": "Mindee Client Library for Node.js",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -1,2 +0,5 @@

declare class ErrorHandler {
/**
* Custom Error handling class.
*/
export declare class ErrorHandler {
throwOnError: boolean;

@@ -7,2 +10,1 @@ constructor(throwOnError?: boolean);

export declare const errorHandler: ErrorHandler;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorHandler = void 0;
exports.errorHandler = exports.ErrorHandler = void 0;
const logger_1 = require("../logger");
/**
* Custom Error handling class.
*/
class ErrorHandler {

@@ -18,2 +21,3 @@ constructor(throwOnError = true) {

}
exports.ErrorHandler = ErrorHandler;
exports.errorHandler = new ErrorHandler();

@@ -1,1 +0,1 @@

export { MindeeError, MindeeMimeTypeError } from "./MindeeError";
export { MindeeError, MindeeMimeTypeError } from "./mindeeError";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MindeeMimeTypeError = exports.MindeeError = void 0;
var MindeeError_1 = require("./MindeeError");
Object.defineProperty(exports, "MindeeError", { enumerable: true, get: function () { return MindeeError_1.MindeeError; } });
Object.defineProperty(exports, "MindeeMimeTypeError", { enumerable: true, get: function () { return MindeeError_1.MindeeMimeTypeError; } });
var mindeeError_1 = require("./mindeeError");
Object.defineProperty(exports, "MindeeError", { enumerable: true, get: function () { return mindeeError_1.MindeeError; } });
Object.defineProperty(exports, "MindeeMimeTypeError", { enumerable: true, get: function () { return mindeeError_1.MindeeMimeTypeError; } });

@@ -27,2 +27,3 @@ "use strict";

exports.ApiSettings = exports.STANDARD_API_OWNER = exports.API_HOST_ENVVAR_NAME = exports.API_KEY_ENVVAR_NAME = void 0;
/* eslint-disable @typescript-eslint/naming-convention */
const logger_1 = require("../logger");

@@ -29,0 +30,0 @@ const package_json_1 = require("../../package.json");

@@ -18,2 +18,3 @@ "use strict";

const baseEndpoint_1 = require("./baseEndpoint");
const responseValidation_1 = require("./responseValidation");
/**

@@ -44,5 +45,4 @@ * Endpoint for a product (OTS or Custom).

const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
const statusCode = response.messageObj.statusCode;
if (statusCode === undefined || statusCode >= 400) {
(0, error_1.handleError)(this.urlName, response, statusCode, response.messageObj?.statusMessage);
if (!(0, responseValidation_1.isValidSyncResponse)(response)) {
(0, error_1.handleError)(this.urlName, response, response.messageObj?.statusMessage);
}

@@ -64,5 +64,4 @@ return response;

const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
const statusCode = response.messageObj.statusCode;
if (statusCode === undefined || statusCode >= 400) {
(0, error_1.handleError)(this.urlName, response, statusCode, response.messageObj?.statusMessage);
if (!(0, responseValidation_1.isValidAsyncResponse)(response)) {
(0, error_1.handleError)(this.urlName, response, response.messageObj?.statusMessage);
}

@@ -81,6 +80,4 @@ return response;

const queueStatusCode = queueResponse.messageObj.statusCode;
if (queueStatusCode === undefined ||
queueStatusCode < 200 ||
queueStatusCode > 400) {
(0, error_1.handleError)(this.urlName, queueResponse, queueStatusCode, queueResponse.messageObj?.statusMessage);
if (!(0, responseValidation_1.isValidAsyncResponse)(queueResponse)) {
(0, error_1.handleError)(this.urlName, queueResponse, queueResponse.messageObj?.statusMessage);
}

@@ -102,5 +99,4 @@ if (queueStatusCode === 302 &&

const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentGetReq).call(this, documentId);
const statusCode = response.messageObj.statusCode;
if (statusCode === undefined || statusCode >= 400) {
(0, error_1.handleError)("document", response, statusCode, response.messageObj?.statusMessage);
if (!(0, responseValidation_1.isValidAsyncResponse)(response)) {
(0, error_1.handleError)("document", response, response.messageObj?.statusMessage);
}

@@ -116,5 +112,4 @@ return response;

const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentFeedbackPutReq).call(this, documentId, feedback);
const statusCode = response.messageObj.statusCode;
if (statusCode === undefined || statusCode >= 400) {
(0, error_1.handleError)("feedback", response, statusCode, response.messageObj?.statusMessage);
if (!(0, responseValidation_1.isValidSyncResponse)(response)) {
(0, error_1.handleError)("feedback", response, response.messageObj?.statusMessage);
}

@@ -121,0 +116,0 @@ return response;

import { MindeeError } from "../errors";
import { StringDict } from "../parsing/common";
import { EndpointResponse } from "./baseEndpoint";
export declare function handleError(urlName: string, response: EndpointResponse, code?: number, serverError?: string): void;
export declare function handleError(urlName: string, response: EndpointResponse, serverError?: string): void;
/**

@@ -6,0 +6,0 @@ * `Error` wrapper for server (HTTP) errors.

@@ -6,6 +6,10 @@ "use strict";

const handler_1 = require("../errors/handler");
function handleError(urlName, response, code, serverError) {
if (code === undefined) {
throw new MindeeHttpError({ message: "Missing HTTP Error code.", details: response.data, undefined }, urlName);
function handleError(urlName, response, serverError) {
let code;
if (response.messageObj.statusCode && !Number.isNaN(response.data.statusCode)) {
code = response.messageObj.statusCode;
}
else {
code = 500;
}
let errorObj;

@@ -12,0 +16,0 @@ try {

@@ -5,1 +5,2 @@ export { Endpoint } from "./endpoint";

export { MindeeHttpError, MindeeHttp400Error, MindeeHttp401Error, MindeeHttp403Error, MindeeHttp404Error, MindeeHttp413Error, MindeeHttp429Error, MindeeHttp500Error, MindeeHttp504Error, handleError, } from "./error";
export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, } from "./responseValidation";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleError = exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.ApiSettings = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = exports.Endpoint = void 0;
exports.cleanRequestData = exports.isValidAsyncResponse = exports.isValidSyncResponse = exports.handleError = exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.ApiSettings = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = exports.Endpoint = void 0;
var endpoint_1 = require("./endpoint");

@@ -21,1 +21,5 @@ Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return endpoint_1.Endpoint; } });

Object.defineProperty(exports, "handleError", { enumerable: true, get: function () { return error_1.handleError; } });
var responseValidation_1 = require("./responseValidation");
Object.defineProperty(exports, "isValidSyncResponse", { enumerable: true, get: function () { return responseValidation_1.isValidSyncResponse; } });
Object.defineProperty(exports, "isValidAsyncResponse", { enumerable: true, get: function () { return responseValidation_1.isValidAsyncResponse; } });
Object.defineProperty(exports, "cleanRequestData", { enumerable: true, get: function () { return responseValidation_1.cleanRequestData; } });

@@ -1,2 +0,4 @@

/** Options to pass to the `parse` method for cutting multi-page documents. */
/**
* Options to pass to the `parse` method for cutting multi-page documents.
*/
export interface PageOptions {

@@ -18,3 +20,5 @@ /**

}
/** Operation to apply on the document, given the page indexes specified. */
/**
* Operation to apply on the document, given the page indexes specified.
*/
export declare enum PageOptionsOperation {

@@ -21,0 +25,0 @@ /** Only keep pages matching the provided indexes. */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageOptionsOperation = void 0;
/** Operation to apply on the document, given the page indexes specified. */
/**
* Operation to apply on the document, given the page indexes specified.
*/
var PageOptionsOperation;

@@ -6,0 +8,0 @@ (function (PageOptionsOperation) {

@@ -1,5 +0,7 @@

export * as product from "./product/internal";
export * as input from "./input";
export * as geometry from "./geometry";
export * as http from "./http";
export * as imageOperations from "./imageOperations/internal";
export * as parsing from "./parsing";
export * as pdf from "./pdf";
export * as geometry from "./geometry";
export * as http from "./http";
export * as product from "./product/internal";

@@ -26,7 +26,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.http = exports.geometry = exports.pdf = exports.parsing = exports.product = void 0;
exports.product = __importStar(require("./product/internal"));
exports.product = exports.pdf = exports.parsing = exports.imageOperations = exports.http = exports.geometry = exports.input = void 0;
exports.input = __importStar(require("./input"));
exports.geometry = __importStar(require("./geometry"));
exports.http = __importStar(require("./http"));
exports.imageOperations = __importStar(require("./imageOperations/internal"));
exports.parsing = __importStar(require("./parsing"));
exports.pdf = __importStar(require("./pdf"));
exports.geometry = __importStar(require("./geometry"));
exports.http = __importStar(require("./http"));
exports.product = __importStar(require("./product/internal"));

@@ -15,2 +15,4 @@ import { ApiResponse } from "./apiResponse";

availableAt?: Date;
/** Information about an error that occurred during the job processing. */
error?: StringDict;
/** ID of the job. */

@@ -17,0 +19,0 @@ id: string;

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