Skip to content

Commit 8288a82

Browse files
author
FalkWolsky
committed
Updating Stripe and introducing Lowcoder API as Datasource
1 parent 9b4dedd commit 8288a82

File tree

6 files changed

+186565
-41056
lines changed

6 files changed

+186565
-41056
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import bigQueryPlugin from "./bigQuery";
3535
import appConfigPlugin from "./appconfig";
3636
import tursoPlugin from "./turso";
3737
import postmanEchoPlugin from "./postmanEcho";
38+
import lowcoderPlugin from "./lowcoder";
3839

3940
let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
4041
s3Plugin,
@@ -73,6 +74,7 @@ let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
7374
appConfigPlugin,
7475
tursoPlugin,
7576
postmanEchoPlugin,
77+
lowcoderPlugin,
7678
];
7779

7880
try {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { readYaml } from "../../common/util";
2+
import _ from "lodash";
3+
import path from "path";
4+
import { OpenAPIV3, OpenAPI } from "openapi-types";
5+
import { ConfigToType, DataSourcePlugin } from "lowcoder-sdk/dataSource";
6+
import { runOpenApi } from "../openApi";
7+
import { parseOpenApi, ParseOpenApiOptions } from "../openApi/parse";
8+
9+
import spec from './lowcoder.spec.json';
10+
11+
const dataSourceConfig = {
12+
type: "dataSource",
13+
params: [
14+
{
15+
key: "serverURL",
16+
type: "textInput",
17+
label: "Lowcoder API Service URL",
18+
rules: [{ required: true }],
19+
placeholder: "https://<your-lowcoder-api-service>:port",
20+
tooltip: "Input the server url of your self-hosting instance or api-service.lowcoder.cloud if you are running your apps on the free public Community Edition Cloud Service.",
21+
},
22+
{
23+
"type": "groupTitle",
24+
"key": "API Key",
25+
"label": "Api Key Auth"
26+
},
27+
{
28+
type: "password",
29+
key: "bearerAuth.value",
30+
label: "Authorization",
31+
"tooltip": "API Key Authentication with a Bearer token. Copy your API Key here. (e.g. 'Bearer eyJhbGciO...')",
32+
"placeholder": "API Key Authentication with a Bearer token. Copy your API Key here. (e.g. 'Bearer eyJhbGciO...')"
33+
}
34+
]
35+
} as const;
36+
37+
const parseOptions: ParseOpenApiOptions = {
38+
actionLabel: (method: string, path: string, operation: OpenAPI.Operation) => {
39+
return _.upperFirst(operation.operationId || "");
40+
},
41+
};
42+
43+
type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;
44+
45+
const lowcoderPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
46+
id: "lowcoder",
47+
name: "Lowcoder API",
48+
icon: "lowcoder.svg",
49+
category: "api",
50+
dataSourceConfig,
51+
queryConfig: async () => {
52+
const { actions, categories } = await parseOpenApi(spec as unknown as OpenAPI.Document, parseOptions);
53+
return {
54+
type: "query",
55+
label: "Action",
56+
categories: {
57+
label: "Resources",
58+
items: categories,
59+
},
60+
actions,
61+
};
62+
},
63+
run: function (actionData, dataSourceConfig): Promise<any> {
64+
const { serverURL, ...otherDataSourceConfig } = dataSourceConfig;
65+
console.log("Lowcoder API Plugin: run", serverURL, otherDataSourceConfig);
66+
const runApiDsConfig = {
67+
url: "",
68+
serverURL: serverURL,
69+
dynamicParamsConfig: otherDataSourceConfig,
70+
};
71+
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
72+
},
73+
};
74+
75+
export default lowcoderPlugin;

0 commit comments

Comments
 (0)