@activepieces/piece-csv 0.4.15 → 0.4.17
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/package.json +7 -20
- package/src/index.js +157 -20
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/actions/convert-csv-to-json.d.ts +0 -6
- package/src/lib/actions/convert-csv-to-json.d.ts.map +0 -1
- package/src/lib/actions/convert-csv-to-json.js +0 -58
- package/src/lib/actions/convert-csv-to-json.js.map +0 -1
- package/src/lib/actions/convert-excel-to-csv.d.ts +0 -6
- package/src/lib/actions/convert-excel-to-csv.d.ts.map +0 -1
- package/src/lib/actions/convert-excel-to-csv.js +0 -68
- package/src/lib/actions/convert-excel-to-csv.js.map +0 -1
- package/src/lib/actions/convert-json-to-csv.d.ts +0 -6
- package/src/lib/actions/convert-json-to-csv.d.ts.map +0 -1
- package/src/lib/actions/convert-json-to-csv.js +0 -78
- package/src/lib/actions/convert-json-to-csv.js.map +0 -1
package/src/index.d.ts
DELETED
package/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG,2DAUd,CAAC"}
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,iDAAqD;AACrD,2EAAoE;AACpE,2EAAoE;AACpE,6EAAsE;AAEzD,QAAA,GAAG,GAAG,IAAA,8BAAW,EAAC;IAC7B,WAAW,EAAE,KAAK;IAClB,WAAW,EAAE,qBAAqB;IAClC,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,sDAAsD;IAC/D,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,UAAU,EAAE,CAAC,sBAAa,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,qCAAe,EAAE,qCAAe,EAAE,uCAAgB,CAAC;IAC7D,OAAO,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,CAAC;IAChF,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const csvToJsonAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
-
csv_text: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
3
|
-
has_headers: import("@activepieces/pieces-framework").CheckboxProperty<true>;
|
|
4
|
-
delimiter_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
-
}>;
|
|
6
|
-
//# sourceMappingURL=convert-csv-to-json.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-csv-to-json.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/convert-csv-to-json.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;EAiD1B,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.csvToJsonAction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const shared_1 = require("@activepieces/shared");
|
|
7
|
-
const sync_1 = require("csv-parse/sync");
|
|
8
|
-
exports.csvToJsonAction = (0, pieces_framework_1.createAction)({
|
|
9
|
-
audience: 'human',
|
|
10
|
-
name: 'convert_csv_to_json',
|
|
11
|
-
displayName: 'Convert CSV to JSON',
|
|
12
|
-
description: 'This function reads a CSV string and converts it into JSON array format.',
|
|
13
|
-
errorHandlingOptions: {
|
|
14
|
-
continueOnFailure: {
|
|
15
|
-
hide: true,
|
|
16
|
-
},
|
|
17
|
-
retryOnFailure: {
|
|
18
|
-
hide: true,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
props: {
|
|
22
|
-
csv_text: pieces_framework_1.Property.LongText({
|
|
23
|
-
displayName: 'CSV Text',
|
|
24
|
-
defaultValue: '',
|
|
25
|
-
required: true,
|
|
26
|
-
}),
|
|
27
|
-
has_headers: pieces_framework_1.Property.Checkbox({
|
|
28
|
-
displayName: 'Does the CSV have headers?',
|
|
29
|
-
defaultValue: false,
|
|
30
|
-
required: true,
|
|
31
|
-
}),
|
|
32
|
-
delimiter_type: pieces_framework_1.Property.StaticDropdown({
|
|
33
|
-
displayName: 'Delimiter Type',
|
|
34
|
-
description: 'Select the delimiter type for the CSV text.',
|
|
35
|
-
defaultValue: '',
|
|
36
|
-
required: true,
|
|
37
|
-
options: {
|
|
38
|
-
options: [
|
|
39
|
-
{ label: 'Comma', value: ',' },
|
|
40
|
-
{ label: 'Tab', value: '\t' },
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
45
|
-
run(context) {
|
|
46
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const { csv_text, has_headers, delimiter_type } = context.propsValue;
|
|
48
|
-
if (!(0, shared_1.isString)(csv_text)) {
|
|
49
|
-
throw new Error(JSON.stringify({
|
|
50
|
-
message: 'The input should be a string.',
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
const records = (0, sync_1.parse)(csv_text, { delimiter: delimiter_type, columns: has_headers ? true : false });
|
|
54
|
-
return records;
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=convert-csv-to-json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-csv-to-json.js","sourceRoot":"","sources":["../../../../src/lib/actions/convert-csv-to-json.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,i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,EAAC,QAAQ,EAAC,EAAC,SAAS,EAAE,cAAc,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAC,CAAC,CAAC;YAChG,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const excelToCsvAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
-
file: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
3
|
-
sheet_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
-
delimiter_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
-
}>;
|
|
6
|
-
//# sourceMappingURL=convert-excel-to-csv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-excel-to-csv.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/convert-excel-to-csv.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;EAqE3B,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.excelToCsvAction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const XLSX = tslib_1.__importStar(require("xlsx"));
|
|
7
|
-
exports.excelToCsvAction = (0, pieces_framework_1.createAction)({
|
|
8
|
-
audience: 'human',
|
|
9
|
-
name: 'convert_excel_to_csv',
|
|
10
|
-
displayName: 'Convert Excel to CSV',
|
|
11
|
-
description: 'Converts an Excel file (.xlsx or .xls) into CSV text.',
|
|
12
|
-
errorHandlingOptions: {
|
|
13
|
-
continueOnFailure: { hide: true },
|
|
14
|
-
retryOnFailure: { hide: true },
|
|
15
|
-
},
|
|
16
|
-
props: {
|
|
17
|
-
file: pieces_framework_1.Property.File({
|
|
18
|
-
displayName: 'Excel File',
|
|
19
|
-
description: 'The Excel file (.xlsx or .xls) to convert to CSV.',
|
|
20
|
-
required: true,
|
|
21
|
-
}),
|
|
22
|
-
sheet_name: pieces_framework_1.Property.ShortText({
|
|
23
|
-
displayName: 'Sheet Name',
|
|
24
|
-
description: 'Name of the sheet to convert. Leave blank to use the first sheet.',
|
|
25
|
-
required: false,
|
|
26
|
-
}),
|
|
27
|
-
delimiter_type: pieces_framework_1.Property.StaticDropdown({
|
|
28
|
-
displayName: 'Delimiter',
|
|
29
|
-
description: 'Character used to separate values in the output CSV.',
|
|
30
|
-
defaultValue: ',',
|
|
31
|
-
required: true,
|
|
32
|
-
options: {
|
|
33
|
-
options: [
|
|
34
|
-
{ label: 'Comma (,)', value: ',' },
|
|
35
|
-
{ label: 'Tab', value: '\t' },
|
|
36
|
-
{ label: 'Semicolon (;)', value: ';' },
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
run(context) {
|
|
42
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const { file, sheet_name, delimiter_type } = context.propsValue;
|
|
44
|
-
const buffer = Buffer.from(file.base64, 'base64');
|
|
45
|
-
// XLSX (ZIP) starts with PK\x03\x04; XLS (OLE2) starts with \xD0\xCF\x11\xE0.
|
|
46
|
-
// Anything else (HTML, PDF, …) is rejected with a clear message.
|
|
47
|
-
const isXlsx = buffer[0] === 0x50 && buffer[1] === 0x4b;
|
|
48
|
-
const isXls = buffer[0] === 0xd0 && buffer[1] === 0xcf;
|
|
49
|
-
if (!isXlsx && !isXls) {
|
|
50
|
-
throw new Error('The file does not appear to be a valid Excel file (.xlsx or .xls). ' +
|
|
51
|
-
'If you supplied a URL, make sure it points directly to the file download, not a webpage.');
|
|
52
|
-
}
|
|
53
|
-
const workbook = XLSX.read(buffer, { type: 'buffer' });
|
|
54
|
-
const targetSheet = (sheet_name === null || sheet_name === void 0 ? void 0 : sheet_name.trim()) || workbook.SheetNames[0];
|
|
55
|
-
if (!workbook.SheetNames.includes(targetSheet)) {
|
|
56
|
-
throw new Error(`Sheet "${targetSheet}" not found. Available sheets: ${workbook.SheetNames.join(', ')}`);
|
|
57
|
-
}
|
|
58
|
-
const worksheet = workbook.Sheets[targetSheet];
|
|
59
|
-
const csv = XLSX.utils.sheet_to_csv(worksheet, { FS: delimiter_type });
|
|
60
|
-
return {
|
|
61
|
-
csv,
|
|
62
|
-
sheet_name: targetSheet,
|
|
63
|
-
available_sheets: workbook.SheetNames,
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=convert-excel-to-csv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-excel-to-csv.js","sourceRoot":"","sources":["../../../../src/lib/actions/convert-excel-to-csv.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,mDAA6B;AAEhB,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,uDAAuD;IACpE,oBAAoB,EAAE;QACpB,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACjC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAC/B;IACD,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,mEAAmE;YAChF,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,cAAc,EAAE,2BAAQ,CAA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WAAW,CAAC,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CACb,UAAU,WAAW,kCAAkC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxF,CAAC;YACJ,CAAC;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;YAEvE,OAAO;gBACL,GAAG;gBACH,UAAU,EAAE,WAAW;gBACvB,gBAAgB,EAAE,QAAQ,CAAC,UAAU;aACtC,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const jsonToCsvAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
-
markdown: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
3
|
-
json_array: import("@activepieces/pieces-framework").JsonProperty<true>;
|
|
4
|
-
delimiter_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
-
}>;
|
|
6
|
-
//# sourceMappingURL=convert-json-to-csv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-json-to-csv.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/convert-json-to-csv.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe;;;;EAgE1B,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonToCsvAction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const safe_flat_1 = require("safe-flat");
|
|
7
|
-
const sync_1 = require("csv-stringify/sync");
|
|
8
|
-
const markdown = `
|
|
9
|
-
**Notes**:
|
|
10
|
-
* The input should be a JSON array.
|
|
11
|
-
* The JSON object will be flattened If nested and the keys will be used as headers.
|
|
12
|
-
`;
|
|
13
|
-
exports.jsonToCsvAction = (0, pieces_framework_1.createAction)({
|
|
14
|
-
audience: 'human',
|
|
15
|
-
name: 'convert_json_to_csv',
|
|
16
|
-
displayName: 'Convert JSON to CSV',
|
|
17
|
-
description: 'This function reads a JSON array and converts it into CSV format.',
|
|
18
|
-
errorHandlingOptions: {
|
|
19
|
-
continueOnFailure: { hide: true },
|
|
20
|
-
retryOnFailure: { hide: true },
|
|
21
|
-
},
|
|
22
|
-
props: {
|
|
23
|
-
markdown: pieces_framework_1.Property.MarkDown({
|
|
24
|
-
value: markdown,
|
|
25
|
-
}),
|
|
26
|
-
json_array: pieces_framework_1.Property.Json({
|
|
27
|
-
displayName: 'JSON Array',
|
|
28
|
-
defaultValue: [
|
|
29
|
-
{
|
|
30
|
-
name: 'John',
|
|
31
|
-
age: 30,
|
|
32
|
-
address: {
|
|
33
|
-
street: '123 Main St',
|
|
34
|
-
city: 'Los Angeles',
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'Jane',
|
|
39
|
-
age: 25,
|
|
40
|
-
address: {
|
|
41
|
-
street: '123 Main St',
|
|
42
|
-
city: 'Los Angeles',
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
description: 'Provide a JSON array to convert to CSV format.',
|
|
47
|
-
required: true,
|
|
48
|
-
}),
|
|
49
|
-
delimiter_type: pieces_framework_1.Property.StaticDropdown({
|
|
50
|
-
displayName: 'Delimiter Type',
|
|
51
|
-
description: 'Select the delimiter type for the CSV file.',
|
|
52
|
-
defaultValue: ',',
|
|
53
|
-
required: true,
|
|
54
|
-
options: {
|
|
55
|
-
options: [
|
|
56
|
-
{ label: 'Comma', value: ',' },
|
|
57
|
-
{ label: 'Tab', value: '\t' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
run(context) {
|
|
63
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const { json_array, delimiter_type } = context.propsValue;
|
|
65
|
-
if (!Array.isArray(json_array)) {
|
|
66
|
-
throw new Error(JSON.stringify({
|
|
67
|
-
message: 'The input should be a JSON array.',
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
const flattened = json_array.map((item) => (0, safe_flat_1.flatten)(item));
|
|
71
|
-
return (0, sync_1.stringify)(flattened, {
|
|
72
|
-
header: true,
|
|
73
|
-
delimiter: delimiter_type,
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=convert-json-to-csv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-json-to-csv.js","sourceRoot":"","sources":["../../../../src/lib/actions/convert-json-to-csv.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAAoC;AACpC,6CAA+C;AAE/C,MAAM,QAAQ,GAAG;;;;CAIhB,CAAA;AACY,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,mEAAmE;IAChF,oBAAoB,EAAE;QACpB,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACjC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAC/B;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,KAAK,EAAE,QAAQ;SAChB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACxB,WAAW,EAAE,YAAY;YACzB,YAAY,EAAE;gBACZ;oBACE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