@pipedream/supabase 0.3.1 → 0.3.3
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import supabase from "../../supabase.app.mjs";
|
|
2
|
-
import fs from "fs";
|
|
3
2
|
import { parse } from "csv-parse/sync";
|
|
3
|
+
import { getFileStream } from "@pipedream/platform";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "supabase-batch-insert-rows",
|
|
7
7
|
name: "Batch Insert Rows",
|
|
8
8
|
description: "Inserts new rows into a database. [See the documentation](https://supabase.com/docs/reference/javascript/insert)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.4",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
supabase,
|
|
@@ -27,6 +27,12 @@ export default {
|
|
|
27
27
|
],
|
|
28
28
|
reloadProps: true,
|
|
29
29
|
},
|
|
30
|
+
syncDir: {
|
|
31
|
+
type: "dir",
|
|
32
|
+
accessMode: "read",
|
|
33
|
+
sync: true,
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
30
36
|
},
|
|
31
37
|
async additionalProps() {
|
|
32
38
|
const props = {};
|
|
@@ -40,8 +46,8 @@ export default {
|
|
|
40
46
|
if (this.source === "CSV File") {
|
|
41
47
|
props.filePath = {
|
|
42
48
|
type: "string",
|
|
43
|
-
label: "File Path",
|
|
44
|
-
description: "
|
|
49
|
+
label: "File Path or URL",
|
|
50
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
|
45
51
|
};
|
|
46
52
|
}
|
|
47
53
|
return props;
|
|
@@ -59,20 +65,30 @@ export default {
|
|
|
59
65
|
return JSON.parse(arr);
|
|
60
66
|
}
|
|
61
67
|
},
|
|
62
|
-
getRowsFromCSV(filePath) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
: `/tmp/${filePath}`, "utf-8");
|
|
68
|
+
async getRowsFromCSV(filePath) {
|
|
69
|
+
const stream = await getFileStream(filePath);
|
|
70
|
+
const fileContent = await this.streamToUtf8(stream);
|
|
66
71
|
const rows = parse(fileContent, {
|
|
67
72
|
columns: true,
|
|
68
73
|
skip_empty_lines: true,
|
|
69
74
|
});
|
|
70
75
|
return rows;
|
|
71
76
|
},
|
|
77
|
+
async streamToUtf8(stream) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
let data = "";
|
|
80
|
+
|
|
81
|
+
stream.setEncoding("utf-8");
|
|
82
|
+
|
|
83
|
+
stream.on("data", (chunk) => data += chunk);
|
|
84
|
+
stream.on("end", () => resolve(data));
|
|
85
|
+
stream.on("error", reject);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
72
88
|
},
|
|
73
89
|
async run({ $ }) {
|
|
74
90
|
const data = this.source === "CSV File"
|
|
75
|
-
? this.getRowsFromCSV(this.filePath)
|
|
91
|
+
? await this.getRowsFromCSV(this.filePath)
|
|
76
92
|
: this.parseArray(this.data);
|
|
77
93
|
|
|
78
94
|
const response = await this.supabase.insertRow(this.table, data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/supabase",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Pipedream Supabase Components",
|
|
5
5
|
"main": "supabase.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^3.0
|
|
16
|
+
"@pipedream/platform": "^3.1.0",
|
|
17
17
|
"@supabase/supabase-js": "^2.45.6",
|
|
18
18
|
"csv-parse": "^5.5.6"
|
|
19
19
|
}
|