@devs-studio/textract 1.0.0 → 1.0.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.
- package/dist/dto/data/textract-config.d.ts +5 -0
- package/dist/dto/data/textract-config.js +6 -0
- package/dist/dto/data/textract-credentials.d.ts +4 -0
- package/dist/dto/data/textract-credentials.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/services/textract.service.d.ts +8 -0
- package/dist/services/textract.service.js +27 -0
- package/package.json +8 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './services/textract.service';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./services/textract.service"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TextractClient } from "@aws-sdk/client-textract";
|
|
2
|
+
import { TextractConfig } from "../dto/data/textract-config";
|
|
3
|
+
export declare class TextractService {
|
|
4
|
+
private readonly config;
|
|
5
|
+
protected client: TextractClient;
|
|
6
|
+
constructor(config?: TextractConfig | null);
|
|
7
|
+
extractFromBucket(bucket: string, key: string): Promise<string[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextractService = void 0;
|
|
4
|
+
const client_textract_1 = require("@aws-sdk/client-textract");
|
|
5
|
+
class TextractService {
|
|
6
|
+
constructor(config = null) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.client = new client_textract_1.TextractClient(config || {});
|
|
9
|
+
}
|
|
10
|
+
async extractFromBucket(bucket, key) {
|
|
11
|
+
var _a;
|
|
12
|
+
const command = new client_textract_1.DetectDocumentTextCommand({
|
|
13
|
+
Document: {
|
|
14
|
+
S3Object: {
|
|
15
|
+
Bucket: bucket,
|
|
16
|
+
Name: key,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const response = await this.client.send(command);
|
|
21
|
+
// Extraemos el texto línea por línea
|
|
22
|
+
const blockLines = ((_a = response.Blocks) === null || _a === void 0 ? void 0 : _a.filter((b) => b.BlockType === "LINE")) || [];
|
|
23
|
+
const texts = blockLines.map((b) => b.Text || null).filter((t) => t !== null);
|
|
24
|
+
return texts;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TextractService = TextractService;
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devs-studio/textract",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Classes for AWS Textract",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepublish": "npx tsc",
|
|
9
|
+
"build": "npx tsc"
|
|
10
|
+
},
|
|
5
11
|
"keywords": [
|
|
6
12
|
"textract",
|
|
7
13
|
"ocr"
|
|
@@ -17,14 +23,10 @@
|
|
|
17
23
|
"license": "ISC",
|
|
18
24
|
"author": "Devs Studio",
|
|
19
25
|
"type": "commonjs",
|
|
20
|
-
"main": "index.ts",
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
|
-
},
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"@aws-sdk/client-textract": "^3.1007.0"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"typescript": "^5.9.3"
|
|
29
31
|
}
|
|
30
|
-
}
|
|
32
|
+
}
|