Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit d092d8c

Browse files
authored
CON-135: Adjust SDK to the new approach (second try) (#120)
BREAKING CHANGE: - Deprecate `configurationParameters` in plugin and use `inputParameters` from action instead - Deprecate `maintainers` - Rename `title` to `name` in plugins, actions, inputs and outputs - Deprecate `/api/specs/openai/gpts endpoint` on the pluign server - Deprecate `/api/specs/openai/assistants-api` endpoint on the plugin server These endpoints are moved from the individual plugin to the Connery app, which makes more sense and brings more control.
1 parent 6e827f2 commit d092d8c

20 files changed

+90
-951
lines changed

packages/connery/src/api/app.module.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ import { Module } from '@nestjs/common';
22
import { ConfigModule } from '@nestjs/config';
33
import { ActionsController } from './controllers/actions.controller.js';
44
import { PluginController } from './controllers/plugin.controller.js';
5-
import { OpenAiSpecsService } from './services/openai-specs.service.js';
65
import { APP_GUARD } from '@nestjs/core';
76
import { AuthGuard } from './auth.guard.js';
8-
import { OpenAiController } from './controllers/specs.controller.js';
97
import { PluginService } from './services/plugin.service.js';
108
import { PluginConfigService } from './services/plugin-config.service.js';
119
import { HomeController } from './controllers/home.controller.js';
1210

1311
@Module({
1412
imports: [ConfigModule.forRoot({ validate: PluginConfigService.validateEnvConfig }), ConfigModule],
15-
controllers: [HomeController, ActionsController, OpenAiController, PluginController],
13+
controllers: [HomeController, ActionsController, PluginController],
1614
providers: [
1715
{
1816
provide: APP_GUARD,
1917
useClass: AuthGuard,
2018
},
21-
OpenAiSpecsService,
2219
PluginService,
2320
PluginConfigService,
2421
],

packages/connery/src/api/controllers/actions.controller.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
RunActionResponse,
2121
GenericErrorResponse,
2222
} from '../dto.js';
23-
import { PluginConfigService } from '../services/plugin-config.service.js';
2423

2524
@ApiTags('Actions')
2625
@ApiSecurity('ApiKey')
@@ -39,7 +38,7 @@ import { PluginConfigService } from '../services/plugin-config.service.js';
3938
})
4039
@Controller('/api/actions')
4140
export class ActionsController {
42-
constructor(private pluginService: PluginService, private pluginConfigService: PluginConfigService) {}
41+
constructor(private pluginService: PluginService) {}
4342

4443
@ApiOperation({
4544
summary: 'List all actions from the plugin.',
@@ -158,8 +157,7 @@ export class ActionsController {
158157
}
159158

160159
// TODO: throw validation errors as HTTP 400
161-
const defaultConfiguration = this.pluginConfigService.configuration;
162-
const result = await action.run(body.input, defaultConfiguration, body.configuration);
160+
const result = await action.run(body.input);
163161

164162
return {
165163
status: 'success',

packages/connery/src/api/controllers/home.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ export class HomeController {
1212
@ApiExcludeEndpoint()
1313
@Get()
1414
getHomePage(@Res() res: Response) {
15-
const pluginTitle = this.pluginService.plugin.title;
15+
const pluginName = this.pluginService.plugin.name;
1616
const pluginDescription = this.pluginService.plugin.description;
1717
const listOfActions = this.pluginService.plugin.actions
18-
.map((action) => '<span class="italic">' + action.title + '</span>')
18+
.map((action) => '<span class="italic">' + action.name + '</span>')
1919
.join(', ');
2020

2121
const htmlContent = `
2222
<html>
2323
<head>
24-
<title>${pluginTitle} - ${pluginDescription}</title>
24+
<title>${pluginName} - ${pluginDescription}</title>
2525
<meta charset="UTF-8" />
2626
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2727
<script src="https://cdn.tailwindcss.com"></script>
@@ -30,7 +30,7 @@ export class HomeController {
3030
<div class="mx-auto max-w-3xl px-4">
3131
<main class="my-10 grid items-center justify-center gap-4 text-center md:gap-10 lg:gap-16">
3232
<div class="space-y-4">
33-
<h1 class="text-3xl font-bold tracking-tighter sm:text-5xl md:text-6xl">✨<br />${pluginTitle}</h1>
33+
<h1 class="text-3xl font-bold tracking-tighter sm:text-5xl md:text-6xl">✨<br />${pluginName}</h1>
3434
<p class="mx-auto max-w-[600px] text-gray-500 md:text-xl/relaxed lg:text-base/relaxed xl:text-xl/relaxed">
3535
${pluginDescription}
3636
</p>

packages/connery/src/api/controllers/specs.controller.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/connery/src/api/dto.ts

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { ApiHideProperty, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
22
import { ActionRuntime, PluginRuntime } from '../types/runtime';
3-
import {
4-
ConfigurationParameterDefinition,
5-
InputParameterDefinition,
6-
MaintainerDefinition,
7-
OutputParameterDefinition,
8-
ValidationDefinition,
9-
} from '../types/definition';
10-
import { ConfigurationObject, InputObject, OutputObject } from '../types/context';
3+
import { InputParameterDefinition, OutputParameterDefinition, ValidationDefinition } from '../types/definition';
4+
import { InputObject, OutputObject } from '../types/context';
115

126
//
137
// Generic response types
@@ -82,19 +76,6 @@ export class GenericErrorResponse {
8276
// Response types
8377
//
8478

85-
export class Maintainer {
86-
@ApiProperty()
87-
name: string;
88-
89-
@ApiProperty()
90-
email: string;
91-
92-
constructor(maintainer: MaintainerDefinition) {
93-
this.name = maintainer.name;
94-
this.email = maintainer.email;
95-
}
96-
}
97-
9879
export class Validation {
9980
@ApiPropertyOptional()
10081
required?: boolean;
@@ -104,65 +85,16 @@ export class Validation {
10485
}
10586
}
10687

107-
export class ConfigurationParameter {
108-
@ApiProperty()
109-
key: string;
110-
111-
@ApiProperty()
112-
title: string;
113-
114-
@ApiPropertyOptional()
115-
description?: string;
116-
117-
@ApiProperty({
118-
enum: ['string'],
119-
})
120-
type: 'string';
121-
122-
@ApiPropertyOptional({
123-
type: Validation,
124-
})
125-
validation?: Validation;
126-
127-
constructor(configurationParameter: ConfigurationParameterDefinition) {
128-
this.key = configurationParameter.key;
129-
this.title = configurationParameter.title;
130-
this.description = configurationParameter.description;
131-
this.type = configurationParameter.type;
132-
this.validation = new Validation(configurationParameter.validation);
133-
}
134-
}
135-
13688
export class Plugin {
13789
@ApiProperty()
138-
title: string;
90+
name: string;
13991

14092
@ApiPropertyOptional()
14193
description?: string;
14294

143-
@ApiProperty({
144-
type: ConfigurationParameter,
145-
isArray: true,
146-
title: 'Metadata of the plugin configuration parameters.',
147-
description:
148-
'The configuration parameters are used to configure the plugin and its actions. For example, the API keys, the URLs, credentials, etc., can be configured here to be used in the actions. Configuration parameters can be set in the environment variables of the plugin. But also, they can be set when running an action. The configuration parameters set when running an action will override the configuration parameters set in the environment variables.',
149-
})
150-
configurationParameters: ConfigurationParameter[];
151-
152-
@ApiProperty({
153-
type: Maintainer,
154-
isArray: true,
155-
title: 'The maintainers of the plugin.',
156-
})
157-
maintainers: Maintainer[];
158-
15995
constructor(plugin: PluginRuntime) {
160-
this.title = plugin.title;
96+
this.name = plugin.name;
16197
this.description = plugin.description;
162-
this.configurationParameters = plugin.configurationParameters.map(
163-
(configurationParameter) => new ConfigurationParameter(configurationParameter),
164-
);
165-
this.maintainers = plugin.maintainers.map((maintainer) => new Maintainer(maintainer));
16698
}
16799
}
168100

@@ -171,7 +103,7 @@ export class InputParameter {
171103
key: string;
172104

173105
@ApiProperty()
174-
title: string;
106+
name: string;
175107

176108
@ApiPropertyOptional()
177109
description?: string;
@@ -188,7 +120,7 @@ export class InputParameter {
188120

189121
constructor(inputParameter: InputParameterDefinition) {
190122
this.key = inputParameter.key;
191-
this.title = inputParameter.title;
123+
this.name = inputParameter.name;
192124
this.description = inputParameter.description;
193125
this.type = inputParameter.type;
194126
this.validation = new Validation(inputParameter.validation);
@@ -200,7 +132,7 @@ export class OutputParameter {
200132
key: string;
201133

202134
@ApiProperty()
203-
title: string;
135+
name: string;
204136

205137
@ApiPropertyOptional()
206138
description?: string;
@@ -217,7 +149,7 @@ export class OutputParameter {
217149

218150
constructor(outputParameter: OutputParameterDefinition) {
219151
this.key = outputParameter.key;
220-
this.title = outputParameter.title;
152+
this.name = outputParameter.name;
221153
this.description = outputParameter.description;
222154
this.type = outputParameter.type;
223155
this.validation = new Validation(outputParameter.validation);
@@ -229,7 +161,7 @@ export class Action {
229161
key: string;
230162

231163
@ApiProperty()
232-
title: string;
164+
name: string;
233165

234166
@ApiPropertyOptional()
235167
description?: string;
@@ -255,7 +187,7 @@ export class Action {
255187

256188
constructor(action: ActionRuntime) {
257189
this.key = action.key;
258-
this.title = action.title;
190+
this.name = action.name;
259191
this.description = action.description;
260192
this.type = action.type;
261193
this.inputParameters = action.inputParameters.map((inputParameter) => new InputParameter(inputParameter));
@@ -307,8 +239,7 @@ export class RunActionRequest {
307239
[key: string]: any;
308240
};
309241

310-
constructor(input: InputObject, configuration?: ConfigurationObject) {
242+
constructor(input: InputObject) {
311243
this.input = input;
312-
this.configuration = configuration;
313244
}
314245
}

packages/connery/src/api/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ async function initOpeApiSpec(app: INestApplication) {
7575
.addApiKey({ type: 'apiKey', in: 'header', name: 'x-api-key' }, 'ApiKey')
7676
.addTag('Plugin')
7777
.addTag('Actions')
78-
.addTag('Specs', 'Action specifications for different clients.')
79-
.addServer(pluginConfigService.pluginServerUrl, 'Plugin URL')
8078
.build();
8179
const document = SwaggerModule.createDocument(app, config);
8280

0 commit comments

Comments
 (0)