Skip to content

Commit a3fc994

Browse files
author
Thomasr
committed
Add dynamo spec version
1 parent 733591c commit a3fc994

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

server/node-service/src/plugins/dynamodb/dataSourceConfig.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { ConfigToType } from "lowcoder-sdk/dataSource";
2-
2+
import { specsToOptions } from "../../common/util";
3+
const specs = {
4+
"v1.0": ""
5+
}
36
const dataSourceConfig = {
47
type: "dataSource",
58
params: [
@@ -27,6 +30,14 @@ const dataSourceConfig = {
2730
label: "Region",
2831
defaultValue: "us-west-1",
2932
},
33+
{
34+
label: "Spec Version",
35+
key: "specVersion",
36+
type: "select",
37+
tooltip: "Version of the spec file.",
38+
placeholder: "v1.0",
39+
options: specsToOptions(specs)
40+
},
3041
],
3142
} as const;
3243

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import dataSourceConfig, { DataSourceDataType } from "./dataSourceConfig";
33
import queryConfig, { ActionDataType } from "./queryConfig";
44
import { runDynamoDbQuery } from "./run";
55

6+
const specs = {
7+
"v1.0": queryConfig
8+
}
9+
610
const dynamoDBPlugin: DataSourcePlugin<ActionDataType, DataSourceDataType> = {
711
id: "dynamodb",
812
name: "DynamoDB",
913
category: "database",
1014
icon: "dynamodb.svg",
1115
dataSourceConfig,
12-
queryConfig,
16+
queryConfig: async (data) => {
17+
return specs[data.specVersion as keyof typeof specs]
18+
},
1319
run: async function (actionData, dataSourceConfig): Promise<any> {
1420
return runDynamoDbQuery(actionData, dataSourceConfig);
1521
},

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import spec from "./spec.json";
77
import { specsToOptions } from "../../common/util";
88
const specs = {
99
"v1.0": spec,
10-
"v2.0": spec,
1110
}
1211

1312
export function prepareServerUrl(url: string) {
@@ -70,8 +69,8 @@ const n8nPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
7069
icon: "n8n.svg",
7170
category: "api",
7271
dataSourceConfig,
73-
queryConfig: async () => {
74-
const { actions, categories } = await parseOpenApi(spec as OpenAPI.Document, parseOptions);
72+
queryConfig: async (data) => {
73+
const { actions, categories } = await parseOpenApi(specs[data.specVersion as keyof typeof specs] as OpenAPI.Document, parseOptions);
7574
return {
7675
type: "query",
7776
label: "Operation",
@@ -92,7 +91,7 @@ const n8nPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
9291
},
9392
specVersion: dataSourceConfig.specVersion
9493
};
95-
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
94+
return runOpenApi(actionData, runApiDsConfig, specs[dataSourceConfig.specVersion as keyof typeof specs] as OpenAPIV3.Document);
9695
},
9796
};
9897

0 commit comments

Comments
 (0)