Skip to content

Commit 2f9d892

Browse files
author
FalkWolsky
committed
Updating Node-Service
1 parent edcd490 commit 2f9d892

File tree

9 files changed

+1915
-2294
lines changed

9 files changed

+1915
-2294
lines changed

server/node-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
"jsonpath": "^1.1.1",
6262
"lodash": "^4.17.21",
6363
"loglevel": "^1.8.1",
64-
"lowcoder-core": "^0.0.8",
65-
"lowcoder-sdk": "2.4.16",
64+
"lowcoder-core": "^0.0.10",
65+
"lowcoder-sdk": "2.4.17",
6666
"morgan": "^1.10.0",
6767
"node-fetch": "2",
6868
"node-firebird": "^1.1.9",

server/node-service/src/common/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ export function dirToSpecList(specDir: string) {
128128
spec,
129129
});
130130
});
131-
logger.info("spec list loaded %s, duration: %d ms",specDir, performance.now() - start);
131+
// logger.info("spec list loaded %s, duration: %d ms",specDir, performance.now() - start);
132132
return specList;
133133
}

server/node-service/src/plugins/apiTemplate/apiTemplate.spec.json

Lines changed: 1799 additions & 0 deletions
Large diffs are not rendered by default.

server/node-service/src/plugins/apiTemplate/apitemplateiov2_api.yaml

Lines changed: 0 additions & 2279 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 './apiTemplate.spec.json';
10+
11+
const dataSourceConfig = {
12+
type: "dataSource",
13+
params: [
14+
{
15+
"type": "groupTitle",
16+
"key": "ApiKeyAuth",
17+
"label": "Api Key Auth"
18+
},
19+
{
20+
"type": "password",
21+
"key": "ApiKeyAuth.value",
22+
"label": "X-API-KEY",
23+
"tooltip": "An API key is needed to be set in the Authorization header of every API call.\nFor additional support you can contact us.\n\n- APITemplate.io expects the API key to be part of all API requests to the server in a header in this format:\n ```\n X-API-KEY: [API_KEY]\n ```\n\n- Optionally we also support Authorization header\n ```\n Authorization: Token [API_KEY]\n ```\n\n**Note: You must replace the API KEY(6fa6g2pdXGIyHRhVlGh7U56Ada1eF) with your API key in the request samples.**\n",
24+
"placeholder": "An API key is needed to be set in the Authorization header of every API call.\nFor additional support you can contact us.\n\n- APITemplate.io expects the API key to be part of all API requests to the server in a header in this format:\n ```\n X-API-KEY: [API_KEY]\n ```\n\n- Optionally we also support Authorization header\n ```\n Authorization: Token [API_KEY]\n ```\n\n**Note: You must replace the API KEY(6fa6g2pdXGIyHRhVlGh7U56Ada1eF) with your API key in the request samples.**\n"
25+
}
26+
]
27+
} as const;
28+
29+
const parseOptions: ParseOpenApiOptions = {
30+
actionLabel: (method: string, path: string, operation: OpenAPI.Operation) => {
31+
return _.upperFirst(operation.operationId || "");
32+
},
33+
};
34+
35+
type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;
36+
37+
const apiTemplatePlugin: DataSourcePlugin<any, DataSourceConfigType> = {
38+
id: "apiTemplate",
39+
name: "ApiTemplate",
40+
icon: "apiTemplate.svg",
41+
category: "Assets",
42+
dataSourceConfig,
43+
queryConfig: async () => {
44+
const { actions, categories } = await parseOpenApi(spec as unknown as OpenAPI.Document, parseOptions);
45+
return {
46+
type: "query",
47+
label: "Action",
48+
categories: {
49+
label: "Resources",
50+
items: categories,
51+
},
52+
actions,
53+
};
54+
},
55+
run: function (actionData, dataSourceConfig): Promise<any> {
56+
const runApiDsConfig = {
57+
url: "",
58+
serverURL: "",
59+
dynamicParamsConfig: dataSourceConfig,
60+
};
61+
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
62+
},
63+
};
64+
65+
export default apiTemplatePlugin;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import postmanEchoPlugin from "./postmanEcho";
3939
import lowcoderPlugin from "./lowcoder";
4040
import supabaseApiPlugin from "./supabaseApi";
4141
import firebirdsqlPlugin from "./firebirdsql";
42+
import apiTemplatePlugin from "./apiTemplate";
4243
// import boomiPlugin from "./boomi";
4344

4445
let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
@@ -90,6 +91,7 @@ let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
9091
googleCloudStorage,
9192
supabasePlugin,
9293
cloudinaryPlugin,
94+
apiTemplatePlugin,
9395
ossPlugin,
9496

9597
// Project Management
@@ -112,4 +114,4 @@ try {
112114
console.info("using ee plugins");
113115
} catch { }
114116

115-
export default plugins;
117+
export default plugins;

server/node-service/src/services/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export function listPlugins(ctx: PluginContext, ids: string[] = []) {
189189
const pluginMeta = {
190190
...plugin,
191191
shouldValidateDataSourceConfig: !!plugin.validateDataSourceConfig,
192-
} as DataSourcePluginMeta;
192+
} as unknown as DataSourcePluginMeta;
193193

194194
pluginMetaOps.forEach(([path, fn]) => {
195195
jsonPath.apply(pluginMeta, path, fn);
Lines changed: 34 additions & 0 deletions
Loading

server/node-service/yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7689,16 +7689,16 @@ __metadata:
76897689
languageName: node
76907690
linkType: hard
76917691

7692-
"lowcoder-core@npm:^0.0.8":
7693-
version: 0.0.8
7694-
resolution: "lowcoder-core@npm:0.0.8"
7692+
"lowcoder-core@npm:^0.0.10":
7693+
version: 0.0.10
7694+
resolution: "lowcoder-core@npm:0.0.10"
76957695
dependencies:
76967696
"@rollup/plugin-commonjs": ^23.0.0
76977697
"@rollup/plugin-node-resolve": ^15.0.0
76987698
intl-messageformat: ^10.2.1
76997699
lodash: ^4.17.21
77007700
lru-cache: ^7.14.1
7701-
checksum: 67f6ddc1b924d96d5d2ba0fca05b50bf91035b3d24d51acf89e0e40ca466121ba0f220f7162215b71077a43025b9df0a9b55aee48a937605a73fec4a06b71cac
7701+
checksum: f41ae738c8c46df132d8bb31a749e4aa0542e087302cefe078b55cb503372c9979e2e97c926d3ca1592de3aad64a70e8dab2454458b593f1f983f27ad4f85708
77027702
languageName: node
77037703
linkType: hard
77047704

@@ -7743,8 +7743,8 @@ __metadata:
77437743
jsonpath: ^1.1.1
77447744
lodash: ^4.17.21
77457745
loglevel: ^1.8.1
7746-
lowcoder-core: ^0.0.8
7747-
lowcoder-sdk: 2.4.16
7746+
lowcoder-core: ^0.0.10
7747+
lowcoder-sdk: 2.4.17
77487748
morgan: ^1.10.0
77497749
nock: ^13.3.0
77507750
node-fetch: 2
@@ -7765,15 +7765,15 @@ __metadata:
77657765
languageName: unknown
77667766
linkType: soft
77677767

7768-
"lowcoder-sdk@npm:2.4.16":
7769-
version: 2.4.16
7770-
resolution: "lowcoder-sdk@npm:2.4.16"
7768+
"lowcoder-sdk@npm:2.4.17":
7769+
version: 2.4.17
7770+
resolution: "lowcoder-sdk@npm:2.4.17"
77717771
dependencies:
77727772
prettier: ^3.1.1
77737773
peerDependencies:
77747774
react: ">=18"
77757775
react-dom: ">=18"
7776-
checksum: d22d03e928f4f0743eba4a0568cd942cece308eb592741dd9247fc959739d22178ffab59710d27817a4d1ac1ba78a09c0aaacaf525511e37b03147cfccc6275c
7776+
checksum: d4ef5af5e90070aa55b04a190c6b4ad24a28101836db30b21629ff0a3e2428b0daf29b1670a4a44418cd58d18384ef8d19d3327d9f057c459b560f0c357b675b
77777777
languageName: node
77787778
linkType: hard
77797779

0 commit comments

Comments
 (0)