@activepieces/piece-csv 0.2.2 → 0.3.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/package.json +11 -7
- package/src/index.d.ts +1 -1
- package/src/index.js +7 -3
- package/src/index.js.map +1 -1
- package/src/lib/actions/convert-csv-to-json.d.ts +5 -1
- package/src/lib/actions/convert-csv-to-json.js +19 -25
- package/src/lib/actions/convert-csv-to-json.js.map +1 -1
- package/src/lib/actions/convert-json-to-csv.d.ts +5 -1
- package/src/lib/actions/convert-json-to-csv.js +21 -31
- package/src/lib/actions/convert-json-to-csv.js.map +1 -1
- package/src/lib/utils.d.ts +1 -1
- package/src/lib/utils.js +1 -1
- package/src/lib/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-csv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "^1.6.3",
|
|
7
|
+
"dayjs": "1.11.9",
|
|
8
|
+
"is-base64": "1.1.0",
|
|
6
9
|
"lodash": "4.17.21",
|
|
7
|
-
"nanoid": "3.3.
|
|
8
|
-
"papaparse": "5.
|
|
9
|
-
"
|
|
10
|
-
"@activepieces/
|
|
11
|
-
"
|
|
10
|
+
"nanoid": "3.3.6",
|
|
11
|
+
"papaparse": "5.4.1",
|
|
12
|
+
"semver": "7.5.4",
|
|
13
|
+
"@activepieces/pieces-framework": "0.7.15",
|
|
14
|
+
"@activepieces/shared": "0.10.68",
|
|
15
|
+
"tslib": "2.6.2"
|
|
12
16
|
},
|
|
13
17
|
"main": "./src/index.js",
|
|
14
|
-
"
|
|
18
|
+
"type": "commonjs"
|
|
15
19
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const csv: import("@activepieces/pieces-framework").Piece
|
|
1
|
+
export declare const csv: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").PieceAuthProperty>;
|
package/src/index.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.csv = void 0;
|
|
4
4
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
-
const
|
|
5
|
+
const shared_1 = require("@activepieces/shared");
|
|
6
6
|
const convert_csv_to_json_1 = require("./lib/actions/convert-csv-to-json");
|
|
7
|
+
const convert_json_to_csv_1 = require("./lib/actions/convert-json-to-csv");
|
|
7
8
|
exports.csv = (0, pieces_framework_1.createPiece)({
|
|
8
|
-
displayName:
|
|
9
|
+
displayName: 'CSV',
|
|
10
|
+
minimumSupportedRelease: '0.5.0',
|
|
9
11
|
logoUrl: 'https://cdn.activepieces.com/pieces/csv.png',
|
|
10
|
-
|
|
12
|
+
auth: pieces_framework_1.PieceAuth.None(),
|
|
13
|
+
categories: [shared_1.PieceCategory.CORE],
|
|
14
|
+
actions: [convert_csv_to_json_1.parseCSVTextAction, convert_json_to_csv_1.unparseCSVTextAction],
|
|
11
15
|
authors: ['kanarelo'],
|
|
12
16
|
triggers: [],
|
|
13
17
|
});
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/csv/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,iDAAqD;AACrD,2EAAuE;AACvE,2EAAyE;AAE5D,QAAA,GAAG,GAAG,IAAA,8BAAW,EAAC;IAC7B,WAAW,EAAE,KAAK;IAClB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,6CAA6C;IACtD,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,UAAU,EAAE,CAAC,sBAAa,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,wCAAkB,EAAE,0CAAoB,CAAC;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const parseCSVTextAction: 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
|
+
}>;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseCSVTextAction = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
-
exports.
|
|
8
|
-
name:
|
|
9
|
-
displayName:
|
|
10
|
-
description:
|
|
11
|
-
sampleData: [
|
|
12
|
-
"Column 1,Column 2,Column 3,Column 4",
|
|
13
|
-
"1-1,1-2,1-3,1-4"
|
|
14
|
-
],
|
|
7
|
+
exports.parseCSVTextAction = (0, pieces_framework_1.createAction)({
|
|
8
|
+
name: 'convert_csv_to_json',
|
|
9
|
+
displayName: 'Convert CSV to JSON',
|
|
10
|
+
description: 'This function reads a CSV string and converts it into JSON array format.',
|
|
15
11
|
props: {
|
|
16
|
-
|
|
17
|
-
displayName: 'CSV
|
|
18
|
-
defaultValue:
|
|
19
|
-
required: true
|
|
12
|
+
csv_text: pieces_framework_1.Property.LongText({
|
|
13
|
+
displayName: 'CSV Text',
|
|
14
|
+
defaultValue: '',
|
|
15
|
+
required: true,
|
|
20
16
|
}),
|
|
21
17
|
has_headers: pieces_framework_1.Property.Checkbox({
|
|
22
18
|
displayName: 'CSV contains headers',
|
|
@@ -30,25 +26,23 @@ exports.unparseCSVTextAction = (0, pieces_framework_1.createAction)({
|
|
|
30
26
|
required: true,
|
|
31
27
|
options: {
|
|
32
28
|
options: [
|
|
33
|
-
{ label:
|
|
34
|
-
{ label:
|
|
35
|
-
{ label:
|
|
36
|
-
]
|
|
37
|
-
}
|
|
29
|
+
{ label: 'Auto', value: 'auto' },
|
|
30
|
+
{ label: 'Comma', value: ',' },
|
|
31
|
+
{ label: 'Tab', value: '\t' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
38
34
|
}),
|
|
39
35
|
},
|
|
40
36
|
run(context) {
|
|
41
37
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const {
|
|
38
|
+
const { csv_text, has_headers, delimiter_type } = context.propsValue;
|
|
43
39
|
const config = {
|
|
44
40
|
header: has_headers,
|
|
45
|
-
delimiter: delimiter_type ===
|
|
46
|
-
skipEmptyLines: true
|
|
41
|
+
delimiter: delimiter_type === 'auto' ? '' : delimiter_type,
|
|
42
|
+
skipEmptyLines: true,
|
|
47
43
|
};
|
|
48
|
-
|
|
49
|
-
console.debug("Unparse results", results);
|
|
50
|
-
return results;
|
|
44
|
+
return (0, utils_1.parseCSVFile)(csv_text, config);
|
|
51
45
|
});
|
|
52
|
-
}
|
|
46
|
+
},
|
|
53
47
|
});
|
|
54
48
|
//# sourceMappingURL=convert-csv-to-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-csv-to-json.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"convert-csv-to-json.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/csv/src/lib/actions/convert-csv-to-json.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,oCAAwC;AAE3B,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,0EAA0E;IAC5E,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,WAAW,EAAE,sBAAsB;YACnC,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,cAAc,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACtC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,iCAAiC;YAC9C,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;oBAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;iBAC9B;aACF;SACF,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACrE,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,WAAW;gBACnB,SAAS,EAAE,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc;gBAC1D,cAAc,EAAE,IAAI;aACrB,CAAC;YACF,OAAO,IAAA,oBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const unparseCSVTextAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
+
csv_object: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/json-property").JsonProperty<true>;
|
|
3
|
+
has_headers: import("@activepieces/pieces-framework").CheckboxProperty<true>;
|
|
4
|
+
delimiter_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
+
}>;
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.unparseCSVTextAction = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
-
exports.
|
|
8
|
-
name:
|
|
9
|
-
displayName:
|
|
10
|
-
description:
|
|
11
|
-
sampleData: [
|
|
12
|
-
{
|
|
13
|
-
"col1": "value",
|
|
14
|
-
"col2": "value",
|
|
15
|
-
"col3": "value"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"col1": "value",
|
|
19
|
-
"col2": "value",
|
|
20
|
-
"col3": "value"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
7
|
+
exports.unparseCSVTextAction = (0, pieces_framework_1.createAction)({
|
|
8
|
+
name: 'convert_json_to_csv',
|
|
9
|
+
displayName: 'Convert JSON to CSV',
|
|
10
|
+
description: 'This function reads a JSON file and converts it into a CSV file format.',
|
|
23
11
|
props: {
|
|
24
|
-
|
|
25
|
-
displayName: 'CSV
|
|
26
|
-
defaultValue:
|
|
27
|
-
required: true
|
|
12
|
+
csv_object: pieces_framework_1.Property.Json({
|
|
13
|
+
displayName: 'CSV JSON',
|
|
14
|
+
defaultValue: {},
|
|
15
|
+
required: true,
|
|
28
16
|
}),
|
|
29
17
|
has_headers: pieces_framework_1.Property.Checkbox({
|
|
30
18
|
displayName: 'CSV contains headers',
|
|
@@ -38,23 +26,25 @@ exports.parseCSVTextAction = (0, pieces_framework_1.createAction)({
|
|
|
38
26
|
required: true,
|
|
39
27
|
options: {
|
|
40
28
|
options: [
|
|
41
|
-
{ label:
|
|
42
|
-
{ label:
|
|
43
|
-
{ label:
|
|
44
|
-
]
|
|
45
|
-
}
|
|
29
|
+
{ label: 'Auto', value: 'auto' },
|
|
30
|
+
{ label: 'Comma', value: ',' },
|
|
31
|
+
{ label: 'Tab', value: '\t' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
46
34
|
}),
|
|
47
35
|
},
|
|
48
36
|
run(context) {
|
|
49
37
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const {
|
|
38
|
+
const { csv_object, has_headers, delimiter_type } = context.propsValue;
|
|
51
39
|
const config = {
|
|
52
40
|
header: has_headers,
|
|
53
|
-
delimiter: delimiter_type ===
|
|
54
|
-
skipEmptyLines: true
|
|
41
|
+
delimiter: delimiter_type === 'auto' ? '' : delimiter_type,
|
|
42
|
+
skipEmptyLines: true,
|
|
55
43
|
};
|
|
56
|
-
|
|
44
|
+
const results = (0, utils_1.unparseCSVObject)(csv_object, config);
|
|
45
|
+
console.debug('Unparse results', results);
|
|
46
|
+
return results;
|
|
57
47
|
});
|
|
58
|
-
}
|
|
48
|
+
},
|
|
59
49
|
});
|
|
60
50
|
//# sourceMappingURL=convert-json-to-csv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-json-to-csv.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"convert-json-to-csv.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/csv/src/lib/actions/convert-json-to-csv.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,oCAA4C;AAE/B,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,yEAAyE;IAC3E,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,IA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are const parseCSVFile: (csvFile: string, config: Record<string, unknown>) => Promise<unknown>;
|
|
3
3
|
export declare const unparseCSVObject: (csvObject: any, config: UnparseConfig) => string;
|
package/src/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.unparseCSVObject = exports.parseCSVFile = void 0;
|
|
|
4
4
|
const papaparse_1 = require("papaparse");
|
|
5
5
|
const parseCSVFile = (csvFile, config) => new Promise((complete, error) => {
|
|
6
6
|
(0, papaparse_1.parse)(csvFile, Object.assign(Object.assign({}, config), { complete: (results) => {
|
|
7
|
-
console.debug(
|
|
7
|
+
console.debug('csv results received', results);
|
|
8
8
|
complete(results.data);
|
|
9
9
|
}, error }));
|
|
10
10
|
});
|
package/src/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/csv/src/lib/utils.ts"],"names":[],"mappings":";;;AAAA,yCAAuE;AAEhE,MAAM,YAAY,GAAG,CAC1B,OAAe,EACf,MAA+B,EAC/B,EAAE,CACF,IAAI,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;IAC9B,IAAA,iBAAK,EAAC,OAAO,kCACR,MAAM,KACT,QAAQ,EAAE,CAAC,OAA6C,EAAE,EAAE;YAC1D,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;YAC/C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,EACD,KAAK,IACL,CAAC;AACL,CAAC,CAAC,CAAC;AAbQ,QAAA,YAAY,gBAapB;AAEE,MAAM,gBAAgB,GAAG,CAAC,SAAc,EAAE,MAAqB,EAAE,EAAE,CACxE,IAAA,mBAAO,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AADhB,QAAA,gBAAgB,oBACA"}
|