Skip to content

Commit

Permalink
feat(pdf-to-text): add a simple piece for pdf to text parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamkamunhjin committed Mar 20, 2024
1 parent f02d2ed commit b63680e
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/pieces/community/pdf-to-text/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../../../.eslintrc.base.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
7 changes: 7 additions & 0 deletions packages/pieces/community/pdf-to-text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pieces-pdf-to-text

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build pieces-pdf-to-text` to build the library.
9 changes: 9 additions & 0 deletions packages/pieces/community/pdf-to-text/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@activepieces/piece-pdf-to-text",
"version": "0.0.1",
"dependencies": {
"@activepieces/pieces-framework": "*",
"tslib": "2.6.2",
"@activepieces/shared": "*"
}
}
24 changes: 24 additions & 0 deletions packages/pieces/community/pdf-to-text/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "pieces-pdf-to-text",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/pdf-to-text/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/pieces/community/pdf-to-text",
"tsConfig": "packages/pieces/community/pdf-to-text/tsconfig.lib.json",
"packageJson": "packages/pieces/community/pdf-to-text/package.json",
"main": "packages/pieces/community/pdf-to-text/src/index.ts",
"assets": ["packages/pieces/community/pdf-to-text/*.md"]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs pieces-pdf-to-text {args.ver} {args.tag}",
"dependsOn": ["build"]
}
},
"tags": []
}
12 changes: 12 additions & 0 deletions packages/pieces/community/pdf-to-text/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { parseTextFromPdfFile } from './lib/actions/pdf-to-text';

export const pdfToText = createPiece({
displayName: 'Pdf-to-text',
auth: PieceAuth.None(),
minimumSupportedRelease: '0.20.0',
logoUrl: 'https://cdn.activepieces.com/pieces/pdf-to-text.png',
authors: [],
actions: [parseTextFromPdfFile],
triggers: [],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { readPdfText } from 'pdf-text-reader';

export const parseTextFromPdfFile = createAction({
// auth: check https://www.activepieces.com/docs/developers/piece-reference/authentication,
name: 'parseTextFromPdfFile',
displayName: 'Parse text from PDF file',
description: 'Parses texts from PDF file',
props: {
file: Property.LongText({
displayName: 'PDF File URL',
required: true,
}),
},
async run(context) {
// Action logic here
console.dir(context, { depth: null });

const file = context.propsValue.file;
const pdfText = await readPdfText({ url: file });

return pdfText;
},
});
19 changes: 19 additions & 0 deletions packages/pieces/community/pdf-to-text/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}
11 changes: 11 additions & 0 deletions packages/pieces/community/pdf-to-text/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}

0 comments on commit b63680e

Please sign in to comment.