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 './boomi.spec.json' ;
10
+
11
+ const dataSourceConfig = {
12
+ type : "dataSource" ,
13
+ params : [
14
+ {
15
+ key : "serverURL" ,
16
+ type : "textInput" ,
17
+ label : "Boomi API URL" ,
18
+ rules : [ { required : true , message : "The Boomi API url is required" } ] ,
19
+ placeholder : "https://api.boomi.com/api/rest/v1/<atomsphere_account_ID>/" ,
20
+ } ,
21
+ {
22
+ "type" : "groupTitle" ,
23
+ "key" : "basicAuth" ,
24
+ "label" : "HTTP Basic Auth"
25
+ } ,
26
+ {
27
+ "type" : "textInput" ,
28
+ "key" : "basicAuth.username" ,
29
+ "label" : "Username" ,
30
+ "tooltip" : "Basic auth username" ,
31
+ "placeholder" : "<Basic Auth Username>"
32
+ } ,
33
+ {
34
+ "type" : "password" ,
35
+ "key" : "basicAuth.password" ,
36
+ "label" : "Password" ,
37
+ "tooltip" : "Basic auth password" ,
38
+ "placeholder" : "<Basic Auth Password>"
39
+ }
40
+ ]
41
+ } as const ;
42
+
43
+ const parseOptions : ParseOpenApiOptions = {
44
+ actionLabel : ( method : string , path : string , operation : OpenAPI . Operation ) => {
45
+ return _ . upperFirst ( operation . operationId || "" ) ;
46
+ } ,
47
+ } ;
48
+
49
+ type DataSourceConfigType = ConfigToType < typeof dataSourceConfig > ;
50
+
51
+ const boomiPlugin : DataSourcePlugin < any , DataSourceConfigType > = {
52
+ id : "boomi" ,
53
+ name : "Boomi" ,
54
+ icon : "boomi.svg" ,
55
+ category : "Workflow" ,
56
+ dataSourceConfig,
57
+ queryConfig : async ( ) => {
58
+ const { actions, categories } = await parseOpenApi ( spec as unknown as OpenAPI . Document , parseOptions ) ;
59
+ return {
60
+ type : "query" ,
61
+ label : "Action" ,
62
+ categories : {
63
+ label : "Resources" ,
64
+ items : categories ,
65
+ } ,
66
+ actions,
67
+ } ;
68
+ } ,
69
+ run : function ( actionData , dataSourceConfig ) : Promise < any > {
70
+ const { serverURL, ...otherDataSourceConfig } = dataSourceConfig ;
71
+ const runApiDsConfig = {
72
+ url : "" ,
73
+ serverURL : "" ,
74
+ dynamicParamsConfig : otherDataSourceConfig ,
75
+ } ;
76
+ return runOpenApi ( actionData , runApiDsConfig , spec as OpenAPIV3 . Document ) ;
77
+ } ,
78
+ } ;
79
+
80
+ export default boomiPlugin ;
81
+
0 commit comments