@activepieces/piece-mindee 0.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/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-mindee",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "1.2.4",
|
|
7
|
+
"form-data": "4.0.0",
|
|
8
|
+
"nanoid": "3.3.4",
|
|
9
|
+
"@activepieces/framework": "0.3.11",
|
|
10
|
+
"@activepieces/shared": "0.3.7",
|
|
11
|
+
"tslib": "2.4.1"
|
|
12
|
+
},
|
|
13
|
+
"main": "./src/index.js",
|
|
14
|
+
"types": "./src/index.d.ts"
|
|
15
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mindee: import("@activepieces/framework").Piece;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mindee = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const framework_1 = require("@activepieces/framework");
|
|
6
|
+
const package_json_1 = tslib_1.__importDefault(require("../package.json"));
|
|
7
|
+
const predict_document_1 = require("./lib/actions/predict-document");
|
|
8
|
+
exports.mindee = (0, framework_1.createPiece)({
|
|
9
|
+
name: "mindee",
|
|
10
|
+
displayName: "Mindee",
|
|
11
|
+
logoUrl: "https://cdn.activepieces.com/pieces/mindee.png",
|
|
12
|
+
version: package_json_1.default.version,
|
|
13
|
+
authors: ['kanarelo'],
|
|
14
|
+
actions: [predict_document_1.mindeePredictDocumentAction],
|
|
15
|
+
triggers: [],
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/mindee/src/index.ts"],"names":[],"mappings":";;;;AACA,uDAAsD;AACtD,2EAA0C;AAC1C,qEAA6E;AAEhE,QAAA,MAAM,GAAG,IAAA,uBAAW,EAAC;IAChC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,gDAAgD;IACzD,OAAO,EAAE,sBAAW,CAAC,OAAO;IAC5B,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE,CAAC,8CAA2B,CAAC;IACtC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mindeePredictDocumentAction: import("@activepieces/framework").Action;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mindeePredictDocumentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const framework_1 = require("@activepieces/framework");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
|
+
exports.mindeePredictDocumentAction = (0, framework_1.createAction)({
|
|
9
|
+
name: 'mindee_predict_document',
|
|
10
|
+
displayName: 'Extract Document',
|
|
11
|
+
description: 'Parse details of a document using OCR.',
|
|
12
|
+
props: {
|
|
13
|
+
authentication: framework_1.Property.SecretText({
|
|
14
|
+
displayName: 'Api Key',
|
|
15
|
+
description: `
|
|
16
|
+
#### To obtain access your Api Key
|
|
17
|
+
1. Sign up and log in to Mindee
|
|
18
|
+
2. Go to [API Key page](https://platform.mindee.com/api-keys)
|
|
19
|
+
3. Copy the Key and paste below.
|
|
20
|
+
`,
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
account_name: framework_1.Property.ShortText({
|
|
24
|
+
displayName: 'Account Name',
|
|
25
|
+
description: 'Refers to your username or organization name with which you signed up with.',
|
|
26
|
+
required: true,
|
|
27
|
+
defaultValue: 'mindee'
|
|
28
|
+
}),
|
|
29
|
+
api_name: framework_1.Property.StaticDropdown({
|
|
30
|
+
displayName: 'API Name',
|
|
31
|
+
description: 'Refers to the name of the API your are using.',
|
|
32
|
+
required: true,
|
|
33
|
+
defaultValue: 'full',
|
|
34
|
+
options: {
|
|
35
|
+
disabled: false,
|
|
36
|
+
options: [
|
|
37
|
+
{ value: 'bank_account_details/v1', label: "Bank Account Details OCR" },
|
|
38
|
+
{ value: 'expense_reports/v4', label: "Receipt OCR" },
|
|
39
|
+
{ value: 'passport/v1', label: "Passport OCR" },
|
|
40
|
+
{ value: 'invoices/v3', label: "Invoice OCR" },
|
|
41
|
+
{ value: 'proof_of_address/v1', label: "Proof of Address OCR" },
|
|
42
|
+
{ value: 'financial_document/v1', label: "Financial Documents OCR" }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
file: framework_1.Property.LongText({
|
|
47
|
+
displayName: 'File URL',
|
|
48
|
+
description: 'Remote file URL or Base64 string. We currently support .pdf (slower), .jpg, .png, .webp, .tiff and .heic formats',
|
|
49
|
+
required: true
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
sampleData: {
|
|
53
|
+
"api_request": {
|
|
54
|
+
"error": {},
|
|
55
|
+
"resources": [
|
|
56
|
+
"document"
|
|
57
|
+
],
|
|
58
|
+
"status": "success",
|
|
59
|
+
"status_code": 201,
|
|
60
|
+
"url": "http://api.mindee.net/v1/products/mindee/invoices/v3/predict"
|
|
61
|
+
},
|
|
62
|
+
"document": {
|
|
63
|
+
"id": "ecdbe7bd-1037-47a5-87a8-b90d49475a1f",
|
|
64
|
+
"name": "sample_invoce.jpeg",
|
|
65
|
+
"n_pages": 1,
|
|
66
|
+
"is_rotation_applied": true,
|
|
67
|
+
"inference": {
|
|
68
|
+
"started_at": "2021-05-06T16:37:28+00:00",
|
|
69
|
+
"finished_at": "2021-05-06T16:37:29+00:00",
|
|
70
|
+
"processing_time": 1.125,
|
|
71
|
+
"pages": [
|
|
72
|
+
{
|
|
73
|
+
"id": 0,
|
|
74
|
+
"orientation": { "value": 0 },
|
|
75
|
+
"prediction": {},
|
|
76
|
+
"extras": {}
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"prediction": {},
|
|
80
|
+
"extras": {}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
run: ({ propsValue: { authentication, api_name, account_name, file } }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
let headers, body = {};
|
|
86
|
+
try {
|
|
87
|
+
const form = new form_data_1.default();
|
|
88
|
+
if (['https:', 'http:'].includes(new URL(file).protocol))
|
|
89
|
+
form.append('document', yield getRemoteFile(file));
|
|
90
|
+
else
|
|
91
|
+
form.append('document', (0, fs_1.createReadStream)(file));
|
|
92
|
+
body = form;
|
|
93
|
+
headers = Object.assign({}, form.getHeaders());
|
|
94
|
+
}
|
|
95
|
+
catch (_) {
|
|
96
|
+
body = { 'document': file };
|
|
97
|
+
headers = { 'Content-Type': 'application/json' };
|
|
98
|
+
}
|
|
99
|
+
const response = yield framework_1.httpClient.sendRequest({
|
|
100
|
+
method: framework_1.HttpMethod.POST,
|
|
101
|
+
url: `https://api.mindee.net/v1/products/${account_name}/${api_name}/predict`,
|
|
102
|
+
headers: Object.assign({ Authorization: `Token ${authentication}` }, headers),
|
|
103
|
+
body: body
|
|
104
|
+
});
|
|
105
|
+
return response.body;
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
function getRemoteFile(url) {
|
|
109
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const response = yield fetch(url);
|
|
111
|
+
return yield response.arrayBuffer();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=predict-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predict-document.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/mindee/src/lib/actions/predict-document.ts"],"names":[],"mappings":";;;;AAAA,uDAAyF;AACzF,2BAAqC;AACrC,kEAAiC;AAEpB,QAAA,2BAA2B,GAAG,IAAA,wBAAY,EAAC;IACtD,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,wCAAwC;IACrD,KAAK,EAAE;QACL,cAAc,EAAE,oBAAQ,CAAC,UAAU,CAAC;YAClC,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE;;;;;OAKZ;YACD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,oBAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,QAAQ;SACvB,CAAC;QACF,QAAQ,EAAE,oBAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,+CAA+C;YAC5D,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,0BAA0B,EAAE;oBACvE,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,EAAE;oBACrD,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE;oBAC/C,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;oBAC9C,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,sBAAsB,EAAE;oBAC/D,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,yBAAyB,EAAE;iBACrE;aACF;SACF,CAAC;QACF,IAAI,EAAE,oB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