Skip to content

Commit 995a502

Browse files
author
sunlei
committed
update datasource icons
1 parent 507a69f commit 995a502

31 files changed

+880
-1927
lines changed

server/node-service/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
"@aws-sdk/client-s3": "^3.238.0",
3636
"@aws-sdk/s3-request-presigner": "^3.241.0",
3737
"@google-cloud/storage": "^6.9.3",
38+
"@supabase/supabase-js": "^2.10.0",
3839
"@types/axios": "^0.14.0",
3940
"@types/express": "^4.17.14",
4041
"@types/jsonpath": "^0.2.0",
4142
"@types/lodash": "^4.14.190",
4243
"@types/morgan": "^1.9.3",
4344
"@types/node": "^18.11.18",
4445
"axios": "^1.2.0",
46+
"base64-arraybuffer": "^1.0.2",
4547
"dynamodb-data-types": "^4.0.1",
4648
"express": "^4.18.2",
4749
"express-async-errors": "^3.1.1",

server/node-service/scripts/openApiDataSourceGen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import postManToOpenApi from "postman-to-openapi";
77
import { program } from "commander";
88

99
interface Options {
10+
force: boolean;
1011
name: string;
1112
url: string;
1213
postMan: boolean;
@@ -15,7 +16,7 @@ interface Options {
1516
}
1617

1718
async function gen(options: Options) {
18-
const { postMan, postManCollectionFile, name, url: specUrl, id: pluginId } = options;
19+
const { postMan, force, postManCollectionFile, name, url: specUrl, id: pluginId } = options;
1920
const id = pluginId ?? _.camelCase(name);
2021
const pluginDir = path.join(path.dirname(__dirname), "src/plugins", id);
2122
const pluginEntryFile = path.join(pluginDir, "index.ts");
@@ -37,7 +38,7 @@ async function gen(options: Options) {
3738
console.info(`plugin dir ${id} created.`);
3839
}
3940

40-
if (fs.existsSync(pluginEntryFile)) {
41+
if (!force && fs.existsSync(pluginEntryFile)) {
4142
console.info(`plugin: ${id} is already existed.`);
4243
return;
4344
}
@@ -99,6 +100,7 @@ const plugins = [
99100
];
100101

101102
program
103+
.option("--force")
102104
.option("--post-man")
103105
.option("-f, --post-man-collection-file [postman collection file path]")
104106
.option("-n, --name <char>")
@@ -109,6 +111,4 @@ program.parse();
109111

110112
const options = program.opts<Options>();
111113

112-
console.info(options);
113-
114114
gen(options);

server/node-service/src/plugins/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import salesForcePlugin from "./salesForce";
2222
import sendGridPlugin from "./sendGrid";
2323
import shopifyPlugin from "./shopify";
2424
import slackPlugin from "./slack";
25-
import supabaseStoragePlugin from "./supabaseStorage";
25+
import supabasePlugin from "./supabase";
2626
import cloudinaryPlugin from "./cloudinary";
2727
import notionPlugin from "./notion";
2828
import datadogPlugin from "./datadog";
@@ -57,7 +57,7 @@ let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
5757
shopifyPlugin,
5858
slackPlugin,
5959
stripePlugin,
60-
supabaseStoragePlugin,
60+
supabasePlugin,
6161
cloudinaryPlugin,
6262
notionPlugin,
6363
datadogPlugin,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ConfigToType } from "openblocks-sdk/dataSource";
2+
3+
export const dataSourceConfig = {
4+
type: "dataSource",
5+
params: [
6+
{
7+
type: "textInput",
8+
key: "projectUrl",
9+
label: "Project URL",
10+
rules: [{ required: true }],
11+
},
12+
{
13+
type: "password",
14+
key: "apiKey",
15+
label: "Api Key",
16+
},
17+
],
18+
} as const;
19+
20+
export type DataSourceDataType = ConfigToType<typeof dataSourceConfig>;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import _ from "lodash";
2+
import { DataSourcePlugin } from "openblocks-sdk/dataSource";
3+
import { dataSourceConfig, DataSourceDataType } from "./dataSourceConfig";
4+
import queryConfig, { ActionDataType } from "./queryConfig";
5+
import run from "./run";
6+
import { ServiceError } from "../../common/error";
7+
8+
const supabasePlugin: DataSourcePlugin<ActionDataType, DataSourceDataType> = {
9+
id: "supabase",
10+
name: "Supabase",
11+
icon: "supabase.svg",
12+
category: "api",
13+
dataSourceConfig,
14+
queryConfig,
15+
run: async function (actionData, dataSourceConfig) {
16+
try {
17+
return await run(actionData, dataSourceConfig);
18+
} catch (e: any) {
19+
if ((e as any).__isStorageError) {
20+
throw new ServiceError(e.message || e.cause);
21+
}
22+
throw e;
23+
}
24+
},
25+
};
26+
27+
export default supabasePlugin;
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import { ConfigToType, QueryConfig } from "openblocks-sdk/dataSource";
2+
3+
const bucketActionParam = {
4+
key: "bucket",
5+
type: "textInput",
6+
label: "Bucket",
7+
} as const;
8+
9+
const returnSignedUrlParam = {
10+
key: "returnSignedUrl",
11+
type: "switch",
12+
label: "Return signed url",
13+
placeholder: "false",
14+
} as const;
15+
16+
enum SupabaseCategory {
17+
Storage = "Firestore",
18+
}
19+
20+
const categories = {
21+
label: "Service",
22+
items: [{ label: "Storage", value: SupabaseCategory.Storage }],
23+
};
24+
25+
const queryConfig = {
26+
type: "query",
27+
categories,
28+
label: "Action",
29+
actions: [
30+
...(
31+
[
32+
{
33+
actionName: "listBuckets",
34+
label: "List Buckets",
35+
params: [],
36+
},
37+
{
38+
actionName: "listObjects",
39+
label: "List Files",
40+
params: [
41+
bucketActionParam,
42+
{
43+
key: "path",
44+
type: "textInput",
45+
label: "Path",
46+
},
47+
{
48+
key: "search",
49+
type: "textInput",
50+
label: "Search",
51+
},
52+
{
53+
key: "limit",
54+
type: "numberInput",
55+
defaultValue: 10,
56+
label: "Limit",
57+
},
58+
{
59+
key: "offset",
60+
type: "numberInput",
61+
defaultValue: 0,
62+
label: "Offset",
63+
},
64+
{
65+
key: "sortBy",
66+
type: "jsonInput",
67+
defaultValue: JSON.stringify({ column: "name", order: "asc" }, null, 4),
68+
label: "Sort By",
69+
},
70+
returnSignedUrlParam,
71+
],
72+
},
73+
{
74+
actionName: "readFile",
75+
label: "Read File",
76+
params: [
77+
bucketActionParam,
78+
{
79+
key: "fileName",
80+
type: "textInput",
81+
label: "File Name",
82+
},
83+
{
84+
key: "encoding",
85+
type: "select",
86+
label: "Data Type",
87+
options: [
88+
{ label: "Base64", value: "base64" },
89+
{ label: "Text", value: "utf8" },
90+
],
91+
},
92+
{
93+
key: "transform",
94+
type: "jsonInput",
95+
label: "Transform",
96+
tooltip:
97+
"Transform the asset before serving it to the client, [more information](https://supabase.com/docs/reference/javascript/storage-from-download).",
98+
},
99+
],
100+
},
101+
{
102+
actionName: "uploadData",
103+
label: "Upload File",
104+
params: [
105+
bucketActionParam,
106+
{
107+
key: "fileName",
108+
type: "textInput",
109+
label: "File Name",
110+
},
111+
{
112+
key: "encoding",
113+
type: "select",
114+
label: "Data Type",
115+
options: [
116+
{ label: "Base64", value: "base64" },
117+
{ label: "Text", value: "utf8" },
118+
],
119+
},
120+
{
121+
key: "data",
122+
type: "textInput",
123+
label: "Data",
124+
},
125+
{
126+
key: "contentType",
127+
type: "textInput",
128+
label: "Content-Type",
129+
placeholder: "image/png",
130+
},
131+
returnSignedUrlParam,
132+
],
133+
},
134+
{
135+
actionName: "deleteFile",
136+
label: "Delete File",
137+
params: [
138+
bucketActionParam,
139+
{
140+
key: "fileName",
141+
type: "textInput",
142+
label: "fileName",
143+
},
144+
],
145+
},
146+
{
147+
actionName: "createSignedUrl",
148+
label: "Create Signed URL",
149+
params: [
150+
bucketActionParam,
151+
{
152+
key: "fileName",
153+
type: "textInput",
154+
label: "fileName",
155+
},
156+
],
157+
},
158+
] as const
159+
).map((i) => ({ ...i, category: [SupabaseCategory.Storage] })),
160+
],
161+
} as const;
162+
163+
export type ActionDataType = ConfigToType<typeof queryConfig>;
164+
165+
export default queryConfig;

0 commit comments

Comments
 (0)