@pipedream/supabase 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/LICENSE +7 -0
- package/actions/delete-row/delete-row.mjs +40 -0
- package/actions/insert-row/insert-row.mjs +32 -0
- package/actions/remote-procedure-call/remote-procedure-call.mjs +30 -0
- package/actions/select-row/select-row.mjs +37 -0
- package/actions/update-row/update-row.mjs +47 -0
- package/actions/upsert-row/upsert-row.mjs +32 -0
- package/package.json +19 -0
- package/supabase.app.mjs +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2020 Pipedream, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-delete-row",
|
|
5
|
+
name: "Delete Row",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Deletes row(s) in a database. [See the docs here](https://supabase.com/docs/reference/javascript/delete)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
table: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
supabase,
|
|
14
|
+
"table",
|
|
15
|
+
],
|
|
16
|
+
description: "Name of the table to delete row(s) from",
|
|
17
|
+
},
|
|
18
|
+
column: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
supabase,
|
|
21
|
+
"column",
|
|
22
|
+
],
|
|
23
|
+
description: "Search column to find row(s) to delete",
|
|
24
|
+
},
|
|
25
|
+
value: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
supabase,
|
|
28
|
+
"value",
|
|
29
|
+
],
|
|
30
|
+
description: "Value of the search column in the row(s) to delete",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
async run({ $ }) {
|
|
34
|
+
const response = await this.supabase.deleteRow(this.table, this.column, this.value);
|
|
35
|
+
if (response) {
|
|
36
|
+
$.export("$summary", `Successfully deleted ${response.length} row(s) from table ${this.table}`);
|
|
37
|
+
}
|
|
38
|
+
return response;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-insert-row",
|
|
5
|
+
name: "Insert Row",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Inserts a new row into a database. [See the docs here](https://supabase.com/docs/reference/javascript/insert)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
table: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
supabase,
|
|
14
|
+
"table",
|
|
15
|
+
],
|
|
16
|
+
description: "Name of the table to insert row into",
|
|
17
|
+
},
|
|
18
|
+
data: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
supabase,
|
|
21
|
+
"data",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async run({ $ }) {
|
|
26
|
+
const response = await this.supabase.insertRow(this.table, this.data);
|
|
27
|
+
if (response) {
|
|
28
|
+
$.export("$summary", `Successfully inserted row into table ${this.table}`);
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-remote-procedure-call",
|
|
5
|
+
name: "Remote Procedure Call",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Call a Postgres function in a database. [See the docs here](https://supabase.com/docs/reference/javascript/rpc)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
functionName: {
|
|
12
|
+
type: "string",
|
|
13
|
+
label: "Function Name",
|
|
14
|
+
description: "The function name to call",
|
|
15
|
+
},
|
|
16
|
+
args: {
|
|
17
|
+
type: "object",
|
|
18
|
+
label: "Arguments",
|
|
19
|
+
description: "The arguments to pass to the function call",
|
|
20
|
+
optional: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
async run({ $ }) {
|
|
24
|
+
const response = await this.supabase.remoteProcedureCall(this.functionName, this.args);
|
|
25
|
+
if (response) {
|
|
26
|
+
$.export("$summary", `Successfully executed remote procedure call ${this.functionName}`);
|
|
27
|
+
}
|
|
28
|
+
return response;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-select-row",
|
|
5
|
+
name: "Select Row",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Selects row(s) in a database. [See the docs here](https://supabase.com/docs/reference/javascript/select)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
table: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
supabase,
|
|
14
|
+
"table",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
column: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
supabase,
|
|
20
|
+
"column",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
value: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
supabase,
|
|
26
|
+
"value",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
const response = await this.supabase.selectRow(this.table, this.column, this.value);
|
|
32
|
+
if (response) {
|
|
33
|
+
$.export("$summary", `Successfully retrieved ${response.length} rows from table ${this.table}`);
|
|
34
|
+
}
|
|
35
|
+
return response;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-update-row",
|
|
5
|
+
name: "Update Row",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Updates row(s) in a database. [See the docs here](https://supabase.com/docs/reference/javascript/update)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
table: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
supabase,
|
|
14
|
+
"table",
|
|
15
|
+
],
|
|
16
|
+
description: "Name of the table to update row(s) in",
|
|
17
|
+
},
|
|
18
|
+
column: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
supabase,
|
|
21
|
+
"column",
|
|
22
|
+
],
|
|
23
|
+
description: "Search column to find row(s) to update",
|
|
24
|
+
},
|
|
25
|
+
value: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
supabase,
|
|
28
|
+
"value",
|
|
29
|
+
],
|
|
30
|
+
description: "Value of the search column in the row(s) to update",
|
|
31
|
+
},
|
|
32
|
+
data: {
|
|
33
|
+
propDefinition: [
|
|
34
|
+
supabase,
|
|
35
|
+
"data",
|
|
36
|
+
],
|
|
37
|
+
description: "Enter the column names and values to update as key/value pairs",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
const response = await this.supabase.updateRow(this.table, this.column, this.value, this.data);
|
|
42
|
+
if (response) {
|
|
43
|
+
$.export("$summary", `Successfully updated ${response.length} row(s) from table ${this.table}`);
|
|
44
|
+
}
|
|
45
|
+
return response;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import supabase from "../../supabase.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "supabase-upsert-row",
|
|
5
|
+
name: "Upsert Row",
|
|
6
|
+
type: "action",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Updates a row in a database or inserts new row if not found. [See the docs here](https://supabase.com/docs/reference/javascript/upsert)",
|
|
9
|
+
props: {
|
|
10
|
+
supabase,
|
|
11
|
+
table: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
supabase,
|
|
14
|
+
"table",
|
|
15
|
+
],
|
|
16
|
+
description: "Name of the table to upsert row",
|
|
17
|
+
},
|
|
18
|
+
data: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
supabase,
|
|
21
|
+
"data",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async run({ $ }) {
|
|
26
|
+
const response = await this.supabase.upsertRow(this.table, this.data);
|
|
27
|
+
if (response) {
|
|
28
|
+
$.export("$summary", `Successfully upserted row into table ${this.table}`);
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
},
|
|
32
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipedream/supabase",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Pipedream Supabase Components",
|
|
5
|
+
"main": "supabase.app.mjs",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pipedream",
|
|
8
|
+
"supabase"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://pipedream.com/apps/supabase",
|
|
11
|
+
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@supabase/supabase-js": "^2.1.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/supabase.app.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createClient } from "@supabase/supabase-js";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: "app",
|
|
5
|
+
app: "supabase",
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
table: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Table",
|
|
10
|
+
description: "Name of the table to search",
|
|
11
|
+
},
|
|
12
|
+
column: {
|
|
13
|
+
type: "string",
|
|
14
|
+
label: "Column",
|
|
15
|
+
description: "Column name to search by",
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
type: "string",
|
|
19
|
+
label: "Value",
|
|
20
|
+
description: "Value of the column specified to search for",
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
type: "object",
|
|
24
|
+
label: "Row Data",
|
|
25
|
+
description: "Enter the column names and values as key/value pairs",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
async _client() {
|
|
30
|
+
return createClient(`https://${this.$auth.subdomain}.supabase.co`, this.$auth.service_key);
|
|
31
|
+
},
|
|
32
|
+
async selectRow(table, column, value) {
|
|
33
|
+
const client = await this._client();
|
|
34
|
+
const { data } = await client
|
|
35
|
+
.from(table)
|
|
36
|
+
.select()
|
|
37
|
+
.eq(column, value);
|
|
38
|
+
return data;
|
|
39
|
+
},
|
|
40
|
+
async insertRow(table, rowData = {}) {
|
|
41
|
+
const client = await this._client();
|
|
42
|
+
const { data } = await client
|
|
43
|
+
.from(table)
|
|
44
|
+
.insert(rowData)
|
|
45
|
+
.select();
|
|
46
|
+
return data;
|
|
47
|
+
},
|
|
48
|
+
async updateRow(table, column, value, rowData = {}) {
|
|
49
|
+
const client = await this._client();
|
|
50
|
+
const { data } = await client
|
|
51
|
+
.from(table)
|
|
52
|
+
.update(rowData)
|
|
53
|
+
.eq(column, value)
|
|
54
|
+
.select();
|
|
55
|
+
return data;
|
|
56
|
+
},
|
|
57
|
+
async upsertRow(table, rowData = {}) {
|
|
58
|
+
const client = await this._client();
|
|
59
|
+
const { data } = await client
|
|
60
|
+
.from(table)
|
|
61
|
+
.upsert(rowData)
|
|
62
|
+
.select();
|
|
63
|
+
return data;
|
|
64
|
+
},
|
|
65
|
+
async deleteRow(table, column, value) {
|
|
66
|
+
const client = await this._client();
|
|
67
|
+
const { data } = await client
|
|
68
|
+
.from(table)
|
|
69
|
+
.delete()
|
|
70
|
+
.eq(column, value)
|
|
71
|
+
.select();
|
|
72
|
+
return data;
|
|
73
|
+
},
|
|
74
|
+
async remoteProcedureCall(functionName, args = {}) {
|
|
75
|
+
const client = await this._client();
|
|
76
|
+
const { data } = await client.rpc(functionName, args);
|
|
77
|
+
return data;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|