@optimizely-opal/opal-tools-sdk 0.1.5-dev → 0.1.8-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +5 -0
- package/.prettierrc +1 -0
- package/README.md +20 -10
- package/dist/auth.d.ts +5 -5
- package/dist/auth.js +2 -2
- package/dist/decorators.d.ts +10 -8
- package/dist/decorators.js +5 -44
- package/dist/index.d.ts +10 -5
- package/dist/index.js +11 -5
- package/dist/models.d.ts +137 -116
- package/dist/models.js +104 -77
- package/dist/proteus.d.ts +1451 -0
- package/dist/proteus.js +86 -0
- package/dist/registerResource.d.ts +60 -0
- package/dist/registerResource.js +59 -0
- package/dist/registerTool.d.ts +79 -0
- package/dist/registerTool.js +106 -0
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +1 -1
- package/dist/service.d.ts +20 -6
- package/dist/service.js +106 -19
- package/eslint.config.js +20 -0
- package/package.json +20 -10
- package/scripts/generate-proteus.ts +135 -0
- package/scripts/lint.sh +7 -0
- package/src/auth.ts +21 -16
- package/src/decorators.ts +32 -67
- package/src/index.ts +10 -5
- package/src/models.ts +133 -103
- package/src/proteus.ts +2129 -0
- package/src/registerResource.ts +82 -0
- package/src/registerTool.ts +171 -0
- package/src/registry.ts +2 -2
- package/src/service.ts +161 -31
- package/tests/integration.test.ts +497 -0
- package/tests/proteus.test.ts +122 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +3 -3
- package/vitest.config.ts +7 -0
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/README.md
CHANGED
|
@@ -71,10 +71,10 @@ interface CalendarParameters {
|
|
|
71
71
|
async function getCalendarEvents(parameters: CalendarParameters, authData?: any) {
|
|
72
72
|
// The authData parameter contains authentication information
|
|
73
73
|
const token = authData?.credentials?.token || '';
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
// Use the token to make authenticated requests
|
|
76
76
|
// ...
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
return { events: ['Meeting at 10:00', 'Lunch at 12:00'] };
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -88,13 +88,13 @@ async function getCalendarEvents(parameters: CalendarParameters, authData?: any)
|
|
|
88
88
|
async function getCalendarAvailability(parameters: CalendarParameters, authData?: any) {
|
|
89
89
|
const provider = authData?.provider || '';
|
|
90
90
|
const token = authData?.credentials?.token || '';
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
if (provider === 'google') {
|
|
93
93
|
// Use Google Calendar API
|
|
94
94
|
} else if (provider === 'microsoft') {
|
|
95
95
|
// Use Microsoft Outlook API
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
return { available: true, provider_used: provider };
|
|
99
99
|
}
|
|
100
100
|
```
|
|
@@ -159,10 +159,10 @@ async function getCalendarEvents(parameters: CalendarParameters, authData?: Auth
|
|
|
159
159
|
The SDK includes Island components for creating interactive UI responses:
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
|
-
import {
|
|
163
|
-
ToolsService,
|
|
164
|
-
tool,
|
|
165
|
-
IslandResponse,
|
|
162
|
+
import {
|
|
163
|
+
ToolsService,
|
|
164
|
+
tool,
|
|
165
|
+
IslandResponse,
|
|
166
166
|
IslandConfig
|
|
167
167
|
} from '@optimizely-opal/opal-tools-sdk';
|
|
168
168
|
import express from 'express';
|
|
@@ -182,7 +182,7 @@ const toolsService = new ToolsService(app);
|
|
|
182
182
|
async function getWeather(parameters: WeatherParameters) {
|
|
183
183
|
// Get weather data (implementation details omitted)
|
|
184
184
|
const weatherData = { temperature: 22, condition: 'sunny', humidity: 65 };
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
// Create an interactive island for weather settings
|
|
187
187
|
const island = new IslandConfig(
|
|
188
188
|
[
|
|
@@ -219,7 +219,7 @@ async function getWeather(parameters: WeatherParameters) {
|
|
|
219
219
|
'button', // Optional island type
|
|
220
220
|
'plus' // Optional island icon
|
|
221
221
|
);
|
|
222
|
-
|
|
222
|
+
|
|
223
223
|
return IslandResponse.create([island]);
|
|
224
224
|
}
|
|
225
225
|
```
|
|
@@ -227,7 +227,9 @@ async function getWeather(parameters: WeatherParameters) {
|
|
|
227
227
|
### Island Components
|
|
228
228
|
|
|
229
229
|
#### IslandConfig.Field
|
|
230
|
+
|
|
230
231
|
Fields represent data inputs in the UI:
|
|
232
|
+
|
|
231
233
|
- `name`: Programmatic field identifier
|
|
232
234
|
- `label`: Human-readable label
|
|
233
235
|
- `type`: Field type (`'string'`, `'boolean'`, `'json'`)
|
|
@@ -236,7 +238,9 @@ Fields represent data inputs in the UI:
|
|
|
236
238
|
- `options`: Available options for selection (optional)
|
|
237
239
|
|
|
238
240
|
#### IslandConfig.Action
|
|
241
|
+
|
|
239
242
|
Actions represent buttons or operations:
|
|
243
|
+
|
|
240
244
|
- `name`: Programmatic action identifier
|
|
241
245
|
- `label`: Human-readable button label
|
|
242
246
|
- `type`: UI element type (typically `'button'`)
|
|
@@ -244,14 +248,18 @@ Actions represent buttons or operations:
|
|
|
244
248
|
- `operation`: Operation type (default: `'create'`)
|
|
245
249
|
|
|
246
250
|
#### IslandConfig
|
|
251
|
+
|
|
247
252
|
Contains the complete island configuration:
|
|
253
|
+
|
|
248
254
|
- `fields`: Array of IslandConfig.Field objects
|
|
249
255
|
- `actions`: Array of IslandConfig.Action objects
|
|
250
256
|
- `type`: Optional island type for custom rendering (optional)
|
|
251
257
|
- `icon`: Optional icon identifier for the island (optional)
|
|
252
258
|
|
|
253
259
|
#### IslandResponse
|
|
260
|
+
|
|
254
261
|
The response wrapper for islands:
|
|
262
|
+
|
|
255
263
|
- Use `IslandResponse.create([islands])` to create responses
|
|
256
264
|
- Supports multiple islands per response
|
|
257
265
|
|
|
@@ -260,11 +268,13 @@ The response wrapper for islands:
|
|
|
260
268
|
The SDK provides comprehensive TypeScript type definitions:
|
|
261
269
|
|
|
262
270
|
### Authentication Types
|
|
271
|
+
|
|
263
272
|
- `AuthData`: Interface containing provider and credentials information
|
|
264
273
|
- `Credentials`: Interface with access_token, org_sso_id, customer_id, instance_id, and product_sku
|
|
265
274
|
- `Environment`: Interface specifying execution mode (`'headless'` or `'interactive'`)
|
|
266
275
|
|
|
267
276
|
### Parameter Types
|
|
277
|
+
|
|
268
278
|
- `ParameterType`: Enum for supported parameter types
|
|
269
279
|
- `Parameter`: Class for tool parameter definitions
|
|
270
280
|
- `Function`: Class for complete tool function definitions
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
interface AuthOptions {
|
|
2
|
+
provider: string;
|
|
3
|
+
required?: boolean;
|
|
4
|
+
scopeBundle: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Middleware to handle authentication requirements
|
|
3
8
|
* @param req Express request
|
|
@@ -5,11 +10,6 @@
|
|
|
5
10
|
* @param next Express next function
|
|
6
11
|
*/
|
|
7
12
|
export declare function authMiddleware(req: any, res: any, next: any): any;
|
|
8
|
-
interface AuthOptions {
|
|
9
|
-
provider: string;
|
|
10
|
-
scopeBundle: string;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}
|
|
13
13
|
/**
|
|
14
14
|
* Decorator to indicate that a tool requires authentication
|
|
15
15
|
* @param options Authentication options
|
package/dist/auth.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.requiresAuth = requiresAuth;
|
|
|
11
11
|
function authMiddleware(req, res, next) {
|
|
12
12
|
const authHeader = req.headers.authorization;
|
|
13
13
|
if (!authHeader && req.authRequired) {
|
|
14
|
-
return res.status(401).json({ error:
|
|
14
|
+
return res.status(401).json({ error: "Authentication required" });
|
|
15
15
|
}
|
|
16
16
|
// The Tools Management Service will provide the appropriate token
|
|
17
17
|
// in the Authorization header
|
|
@@ -31,8 +31,8 @@ function requiresAuth(options) {
|
|
|
31
31
|
const fn = originalMethod;
|
|
32
32
|
fn.__authRequirements__ = {
|
|
33
33
|
provider: options.provider,
|
|
34
|
+
required: options.required ?? true,
|
|
34
35
|
scopeBundle: options.scopeBundle,
|
|
35
|
-
required: options.required ?? true
|
|
36
36
|
};
|
|
37
37
|
return originalMethod.apply(this, args);
|
|
38
38
|
};
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ParameterType } from
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { ParameterType } from "./models";
|
|
3
3
|
interface ParameterDefinition {
|
|
4
|
-
name: string;
|
|
5
|
-
type: ParameterType;
|
|
6
4
|
description: string;
|
|
5
|
+
name: string;
|
|
7
6
|
required: boolean;
|
|
7
|
+
type: ParameterType;
|
|
8
8
|
}
|
|
9
9
|
interface ToolOptions {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
parameters?: ParameterDefinition[];
|
|
13
10
|
authRequirements?: {
|
|
14
11
|
provider: string;
|
|
15
|
-
scopeBundle: string;
|
|
16
12
|
required?: boolean;
|
|
13
|
+
scopeBundle: string;
|
|
17
14
|
};
|
|
15
|
+
description: string;
|
|
16
|
+
name: string;
|
|
17
|
+
parameters?: ParameterDefinition[];
|
|
18
|
+
uiResource?: string;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Decorator to register a function as an Opal tool
|
|
@@ -24,6 +25,7 @@ interface ToolOptions {
|
|
|
24
25
|
* - authRequirements: (Optional) Authentication requirements
|
|
25
26
|
* Format: { provider: "oauth_provider", scopeBundle: "permissions_scope", required: true }
|
|
26
27
|
* Example: { provider: "google", scopeBundle: "calendar", required: true }
|
|
28
|
+
* - uiResource: (Optional) URI of associated UI resource for dynamic rendering (e.g., "ui://my-app/create-form")
|
|
27
29
|
*
|
|
28
30
|
* Note: If your tool requires authentication, define your handler function with two parameters:
|
|
29
31
|
* ```
|
package/dist/decorators.js
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tool = tool;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
5
|
require("reflect-metadata");
|
|
5
6
|
const models_1 = require("./models");
|
|
6
7
|
const registry_1 = require("./registry");
|
|
7
|
-
/**
|
|
8
|
-
* Map a TypeScript type to a ParameterType
|
|
9
|
-
* @param type TypeScript type
|
|
10
|
-
*/
|
|
11
|
-
function mapTypeToParameterType(type) {
|
|
12
|
-
if (type === String || type.name === 'String') {
|
|
13
|
-
return models_1.ParameterType.String;
|
|
14
|
-
}
|
|
15
|
-
else if (type === Number || type.name === 'Number') {
|
|
16
|
-
return models_1.ParameterType.Number;
|
|
17
|
-
}
|
|
18
|
-
else if (type === Boolean || type.name === 'Boolean') {
|
|
19
|
-
return models_1.ParameterType.Boolean;
|
|
20
|
-
}
|
|
21
|
-
else if (type === Array || type.name === 'Array') {
|
|
22
|
-
return models_1.ParameterType.List;
|
|
23
|
-
}
|
|
24
|
-
else if (type === Object || type.name === 'Object') {
|
|
25
|
-
return models_1.ParameterType.Dictionary;
|
|
26
|
-
}
|
|
27
|
-
// Default to string
|
|
28
|
-
return models_1.ParameterType.String;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Extract parameters from a TypeScript interface
|
|
32
|
-
* @param paramType Parameter type object
|
|
33
|
-
*/
|
|
34
|
-
function extractParameters(paramType) {
|
|
35
|
-
const parameters = [];
|
|
36
|
-
// This is very basic and doesn't handle complex types
|
|
37
|
-
// For production use, this would need to be more sophisticated
|
|
38
|
-
for (const key in paramType) {
|
|
39
|
-
if (paramType.hasOwnProperty(key)) {
|
|
40
|
-
const type = typeof paramType[key] === 'undefined' ? String : paramType[key].constructor;
|
|
41
|
-
const required = true; // In a real implementation, we'd detect optional parameters
|
|
42
|
-
parameters.push(new models_1.Parameter(key, mapTypeToParameterType(type), '', // Description - in a real impl we'd use TypeDoc or similar
|
|
43
|
-
required));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return parameters;
|
|
47
|
-
}
|
|
48
8
|
/**
|
|
49
9
|
* Decorator to register a function as an Opal tool
|
|
50
10
|
* @param options Tool options including:
|
|
@@ -53,6 +13,7 @@ function extractParameters(paramType) {
|
|
|
53
13
|
* - authRequirements: (Optional) Authentication requirements
|
|
54
14
|
* Format: { provider: "oauth_provider", scopeBundle: "permissions_scope", required: true }
|
|
55
15
|
* Example: { provider: "google", scopeBundle: "calendar", required: true }
|
|
16
|
+
* - uiResource: (Optional) URI of associated UI resource for dynamic rendering (e.g., "ui://my-app/create-form")
|
|
56
17
|
*
|
|
57
18
|
* Note: If your tool requires authentication, define your handler function with two parameters:
|
|
58
19
|
* ```
|
|
@@ -66,7 +27,7 @@ function tool(options) {
|
|
|
66
27
|
const isMethod = propertyKey && descriptor;
|
|
67
28
|
const handler = isMethod ? descriptor.value : target;
|
|
68
29
|
// Generate endpoint from name - ensure hyphens instead of underscores
|
|
69
|
-
const endpoint = `/tools/${options.name.replace(/_/g,
|
|
30
|
+
const endpoint = `/tools/${options.name.replace(/_/g, "-")}`;
|
|
70
31
|
// Convert parameter definitions to Parameter objects
|
|
71
32
|
const parameters = [];
|
|
72
33
|
if (options.parameters && options.parameters.length > 0) {
|
|
@@ -79,12 +40,12 @@ function tool(options) {
|
|
|
79
40
|
let authRequirements;
|
|
80
41
|
if (options.authRequirements) {
|
|
81
42
|
authRequirements = [
|
|
82
|
-
new models_1.AuthRequirement(options.authRequirements.provider, options.authRequirements.scopeBundle, options.authRequirements.required ?? true)
|
|
43
|
+
new models_1.AuthRequirement(options.authRequirements.provider, options.authRequirements.scopeBundle, options.authRequirements.required ?? true),
|
|
83
44
|
];
|
|
84
45
|
}
|
|
85
46
|
// Register the tool with all services
|
|
86
47
|
for (const service of registry_1.registry.services) {
|
|
87
|
-
service.registerTool(options.name, options.description, handler, parameters, endpoint, authRequirements);
|
|
48
|
+
service.registerTool(options.name, options.description, handler, parameters, endpoint, authRequirements, false, options.uiResource);
|
|
88
49
|
}
|
|
89
50
|
return isMethod ? descriptor : target;
|
|
90
51
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
3
|
-
export { tool } from
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export { requiresAuth } from "./auth";
|
|
3
|
+
export { tool } from "./decorators";
|
|
4
|
+
export * from "./models";
|
|
5
|
+
export { UI } from "./proteus";
|
|
6
|
+
export type * from "./proteus";
|
|
7
|
+
export { registerResource } from "./registerResource";
|
|
8
|
+
export { registerTool } from "./registerTool";
|
|
9
|
+
export type { RequestHandlerExtra } from "./registerTool";
|
|
10
|
+
export { ToolsService } from "./service";
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.ToolsService = exports.registerTool = exports.registerResource = exports.UI = exports.tool = exports.requiresAuth = void 0;
|
|
18
18
|
require("reflect-metadata");
|
|
19
|
-
var service_1 = require("./service");
|
|
20
|
-
Object.defineProperty(exports, "ToolsService", { enumerable: true, get: function () { return service_1.ToolsService; } });
|
|
21
|
-
var decorators_1 = require("./decorators");
|
|
22
|
-
Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return decorators_1.tool; } });
|
|
23
19
|
var auth_1 = require("./auth");
|
|
24
20
|
Object.defineProperty(exports, "requiresAuth", { enumerable: true, get: function () { return auth_1.requiresAuth; } });
|
|
21
|
+
var decorators_1 = require("./decorators");
|
|
22
|
+
Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return decorators_1.tool; } });
|
|
25
23
|
__exportStar(require("./models"), exports);
|
|
24
|
+
var proteus_1 = require("./proteus");
|
|
25
|
+
Object.defineProperty(exports, "UI", { enumerable: true, get: function () { return proteus_1.UI; } });
|
|
26
|
+
var registerResource_1 = require("./registerResource");
|
|
27
|
+
Object.defineProperty(exports, "registerResource", { enumerable: true, get: function () { return registerResource_1.registerResource; } });
|
|
28
|
+
var registerTool_1 = require("./registerTool");
|
|
29
|
+
Object.defineProperty(exports, "registerTool", { enumerable: true, get: function () { return registerTool_1.registerTool; } });
|
|
30
|
+
var service_1 = require("./service");
|
|
31
|
+
Object.defineProperty(exports, "ToolsService", { enumerable: true, get: function () { return service_1.ToolsService; } });
|
package/dist/models.d.ts
CHANGED
|
@@ -2,39 +2,36 @@
|
|
|
2
2
|
* Types of parameters supported by Opal tools
|
|
3
3
|
*/
|
|
4
4
|
export declare enum ParameterType {
|
|
5
|
-
String = "string",
|
|
6
|
-
Integer = "integer",
|
|
7
|
-
Number = "number",
|
|
8
5
|
Boolean = "boolean",
|
|
6
|
+
Dictionary = "object",
|
|
7
|
+
Integer = "integer",
|
|
9
8
|
List = "array",
|
|
10
|
-
|
|
9
|
+
Number = "number",
|
|
10
|
+
String = "string"
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Authentication data for an Opal tool
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
required: boolean;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
15
|
+
export type AuthData = {
|
|
16
|
+
credentials: Credentials;
|
|
17
|
+
provider: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Authentication credentials structure
|
|
21
|
+
*/
|
|
22
|
+
export type Credentials = {
|
|
23
|
+
access_token: string;
|
|
24
|
+
customer_id: string;
|
|
25
|
+
instance_id: string;
|
|
26
|
+
org_sso_id?: string;
|
|
27
|
+
product_sku: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Execution environment for an Opal tool
|
|
31
|
+
*/
|
|
32
|
+
export type Environment = {
|
|
33
|
+
execution_mode: "headless" | "interactive";
|
|
34
|
+
};
|
|
38
35
|
/**
|
|
39
36
|
* Authentication requirements for an Opal tool
|
|
40
37
|
*/
|
|
@@ -54,8 +51,8 @@ export declare class AuthRequirement {
|
|
|
54
51
|
*/
|
|
55
52
|
toJSON(): {
|
|
56
53
|
provider: string;
|
|
57
|
-
scope_bundle: string;
|
|
58
54
|
required: boolean;
|
|
55
|
+
scope_bundle: string;
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
/**
|
|
@@ -67,6 +64,7 @@ export declare class Function {
|
|
|
67
64
|
parameters: Parameter[];
|
|
68
65
|
endpoint: string;
|
|
69
66
|
authRequirements?: AuthRequirement[] | undefined;
|
|
67
|
+
uiResource?: string | undefined;
|
|
70
68
|
/**
|
|
71
69
|
* HTTP method for the endpoint (default: POST)
|
|
72
70
|
*/
|
|
@@ -78,43 +76,50 @@ export declare class Function {
|
|
|
78
76
|
* @param parameters Function parameters
|
|
79
77
|
* @param endpoint API endpoint
|
|
80
78
|
* @param authRequirements Authentication requirements (optional)
|
|
79
|
+
* @param uiResource URI of associated UI resource for dynamic rendering (optional)
|
|
81
80
|
*/
|
|
82
|
-
constructor(name: string, description: string, parameters: Parameter[], endpoint: string, authRequirements?: AuthRequirement[] | undefined);
|
|
81
|
+
constructor(name: string, description: string, parameters: Parameter[], endpoint: string, authRequirements?: AuthRequirement[] | undefined, uiResource?: string | undefined);
|
|
83
82
|
/**
|
|
84
83
|
* Convert to JSON for the discovery endpoint
|
|
85
84
|
*/
|
|
86
85
|
toJSON(): any;
|
|
87
86
|
}
|
|
88
87
|
/**
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
export type Credentials = {
|
|
92
|
-
access_token: string;
|
|
93
|
-
org_sso_id?: string;
|
|
94
|
-
customer_id: string;
|
|
95
|
-
instance_id: string;
|
|
96
|
-
product_sku: string;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Authentication data for an Opal tool
|
|
100
|
-
*/
|
|
101
|
-
export type AuthData = {
|
|
102
|
-
provider: string;
|
|
103
|
-
credentials: Credentials;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Execution environment for an Opal tool
|
|
88
|
+
* Island action definition for interactive UI components
|
|
107
89
|
*/
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
90
|
+
export declare class IslandAction {
|
|
91
|
+
name: string;
|
|
92
|
+
label: string;
|
|
93
|
+
type: string;
|
|
94
|
+
endpoint: string;
|
|
95
|
+
operation: string;
|
|
96
|
+
/**
|
|
97
|
+
* Create a new island action
|
|
98
|
+
* @param name Programmatic action identifier
|
|
99
|
+
* @param label Human-readable button label
|
|
100
|
+
* @param type UI element type
|
|
101
|
+
* @param endpoint API endpoint to call
|
|
102
|
+
* @param operation Operation type
|
|
103
|
+
*/
|
|
104
|
+
constructor(name: string, label: string, type: string, endpoint: string, operation?: string);
|
|
105
|
+
/**
|
|
106
|
+
* Convert to JSON for the discovery endpoint
|
|
107
|
+
*/
|
|
108
|
+
toJSON(): {
|
|
109
|
+
endpoint: string;
|
|
110
|
+
label: string;
|
|
111
|
+
name: string;
|
|
112
|
+
operation: string;
|
|
113
|
+
type: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
111
116
|
/**
|
|
112
117
|
* Island field definition for interactive UI components
|
|
113
118
|
*/
|
|
114
119
|
export declare class IslandField {
|
|
115
120
|
name: string;
|
|
116
121
|
label: string;
|
|
117
|
-
type: "
|
|
122
|
+
type: "boolean" | "json" | "string";
|
|
118
123
|
value: string;
|
|
119
124
|
hidden: boolean;
|
|
120
125
|
options: string[];
|
|
@@ -127,46 +132,17 @@ export declare class IslandField {
|
|
|
127
132
|
* @param hidden Whether to hide from user
|
|
128
133
|
* @param options Available options for selection
|
|
129
134
|
*/
|
|
130
|
-
constructor(name: string, label: string, type: "
|
|
135
|
+
constructor(name: string, label: string, type: "boolean" | "json" | "string", value?: string, hidden?: boolean, options?: string[]);
|
|
131
136
|
/**
|
|
132
137
|
* Convert to JSON for the discovery endpoint
|
|
133
138
|
*/
|
|
134
139
|
toJSON(): {
|
|
135
|
-
|
|
140
|
+
hidden: boolean;
|
|
136
141
|
label: string;
|
|
142
|
+
name: string;
|
|
143
|
+
options: string[];
|
|
137
144
|
type: "string" | "boolean" | "json";
|
|
138
145
|
value: string;
|
|
139
|
-
hidden: boolean;
|
|
140
|
-
options: string[];
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Island action definition for interactive UI components
|
|
145
|
-
*/
|
|
146
|
-
export declare class IslandAction {
|
|
147
|
-
name: string;
|
|
148
|
-
label: string;
|
|
149
|
-
type: string;
|
|
150
|
-
endpoint: string;
|
|
151
|
-
operation: string;
|
|
152
|
-
/**
|
|
153
|
-
* Create a new island action
|
|
154
|
-
* @param name Programmatic action identifier
|
|
155
|
-
* @param label Human-readable button label
|
|
156
|
-
* @param type UI element type
|
|
157
|
-
* @param endpoint API endpoint to call
|
|
158
|
-
* @param operation Operation type
|
|
159
|
-
*/
|
|
160
|
-
constructor(name: string, label: string, type: string, endpoint: string, operation?: string);
|
|
161
|
-
/**
|
|
162
|
-
* Convert to JSON for the discovery endpoint
|
|
163
|
-
*/
|
|
164
|
-
toJSON(): {
|
|
165
|
-
name: string;
|
|
166
|
-
label: string;
|
|
167
|
-
type: string;
|
|
168
|
-
endpoint: string;
|
|
169
|
-
operation: string;
|
|
170
146
|
};
|
|
171
147
|
}
|
|
172
148
|
/**
|
|
@@ -177,8 +153,8 @@ export declare class IslandConfig {
|
|
|
177
153
|
actions: IslandAction[];
|
|
178
154
|
type?: string | undefined;
|
|
179
155
|
icon?: string | undefined;
|
|
180
|
-
static Field: typeof IslandField;
|
|
181
156
|
static Action: typeof IslandAction;
|
|
157
|
+
static Field: typeof IslandField;
|
|
182
158
|
/**
|
|
183
159
|
* Create a new island configuration
|
|
184
160
|
* @param fields List of island fields
|
|
@@ -191,20 +167,20 @@ export declare class IslandConfig {
|
|
|
191
167
|
* Convert to JSON for the discovery endpoint
|
|
192
168
|
*/
|
|
193
169
|
toJSON(): {
|
|
194
|
-
|
|
170
|
+
actions: {
|
|
171
|
+
endpoint: string;
|
|
172
|
+
label: string;
|
|
195
173
|
name: string;
|
|
174
|
+
operation: string;
|
|
175
|
+
type: string;
|
|
176
|
+
}[];
|
|
177
|
+
fields: {
|
|
178
|
+
hidden: boolean;
|
|
196
179
|
label: string;
|
|
180
|
+
name: string;
|
|
181
|
+
options: string[];
|
|
197
182
|
type: "string" | "boolean" | "json";
|
|
198
183
|
value: string;
|
|
199
|
-
hidden: boolean;
|
|
200
|
-
options: string[];
|
|
201
|
-
}[];
|
|
202
|
-
actions: {
|
|
203
|
-
name: string;
|
|
204
|
-
label: string;
|
|
205
|
-
type: string;
|
|
206
|
-
endpoint: string;
|
|
207
|
-
operation: string;
|
|
208
184
|
}[];
|
|
209
185
|
};
|
|
210
186
|
}
|
|
@@ -223,20 +199,20 @@ export declare class IslandResponseConfig {
|
|
|
223
199
|
*/
|
|
224
200
|
toJSON(): {
|
|
225
201
|
islands: {
|
|
226
|
-
|
|
202
|
+
actions: {
|
|
203
|
+
endpoint: string;
|
|
204
|
+
label: string;
|
|
227
205
|
name: string;
|
|
206
|
+
operation: string;
|
|
207
|
+
type: string;
|
|
208
|
+
}[];
|
|
209
|
+
fields: {
|
|
210
|
+
hidden: boolean;
|
|
228
211
|
label: string;
|
|
212
|
+
name: string;
|
|
213
|
+
options: string[];
|
|
229
214
|
type: "string" | "boolean" | "json";
|
|
230
215
|
value: string;
|
|
231
|
-
hidden: boolean;
|
|
232
|
-
options: string[];
|
|
233
|
-
}[];
|
|
234
|
-
actions: {
|
|
235
|
-
name: string;
|
|
236
|
-
label: string;
|
|
237
|
-
type: string;
|
|
238
|
-
endpoint: string;
|
|
239
|
-
operation: string;
|
|
240
216
|
}[];
|
|
241
217
|
}[];
|
|
242
218
|
};
|
|
@@ -268,22 +244,67 @@ export declare class IslandResponse {
|
|
|
268
244
|
toJSON(): {
|
|
269
245
|
config: {
|
|
270
246
|
islands: {
|
|
271
|
-
|
|
247
|
+
actions: {
|
|
248
|
+
endpoint: string;
|
|
249
|
+
label: string;
|
|
272
250
|
name: string;
|
|
251
|
+
operation: string;
|
|
252
|
+
type: string;
|
|
253
|
+
}[];
|
|
254
|
+
fields: {
|
|
255
|
+
hidden: boolean;
|
|
273
256
|
label: string;
|
|
257
|
+
name: string;
|
|
258
|
+
options: string[];
|
|
274
259
|
type: "string" | "boolean" | "json";
|
|
275
260
|
value: string;
|
|
276
|
-
hidden: boolean;
|
|
277
|
-
options: string[];
|
|
278
|
-
}[];
|
|
279
|
-
actions: {
|
|
280
|
-
name: string;
|
|
281
|
-
label: string;
|
|
282
|
-
type: string;
|
|
283
|
-
endpoint: string;
|
|
284
|
-
operation: string;
|
|
285
261
|
}[];
|
|
286
262
|
}[];
|
|
287
263
|
};
|
|
288
264
|
};
|
|
289
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Parameter definition for an Opal tool
|
|
268
|
+
*/
|
|
269
|
+
export declare class Parameter {
|
|
270
|
+
name: string;
|
|
271
|
+
type: ParameterType;
|
|
272
|
+
description: string;
|
|
273
|
+
required: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Create a new parameter definition
|
|
276
|
+
* @param name Parameter name
|
|
277
|
+
* @param type Parameter type
|
|
278
|
+
* @param description Parameter description
|
|
279
|
+
* @param required Whether the parameter is required
|
|
280
|
+
*/
|
|
281
|
+
constructor(name: string, type: ParameterType, description: string, required: boolean);
|
|
282
|
+
/**
|
|
283
|
+
* Convert to JSON for the discovery endpoint
|
|
284
|
+
*/
|
|
285
|
+
toJSON(): {
|
|
286
|
+
description: string;
|
|
287
|
+
name: string;
|
|
288
|
+
required: boolean;
|
|
289
|
+
type: ParameterType;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Resource definition for MCP resources
|
|
294
|
+
*/
|
|
295
|
+
export declare class Resource {
|
|
296
|
+
uri: string;
|
|
297
|
+
name: string;
|
|
298
|
+
description?: string | undefined;
|
|
299
|
+
mimeType?: string | undefined;
|
|
300
|
+
title?: string | undefined;
|
|
301
|
+
/**
|
|
302
|
+
* Create a new resource definition
|
|
303
|
+
* @param uri The unique URI for this resource (e.g., "ui://my-app/create-form")
|
|
304
|
+
* @param name Name of the resource
|
|
305
|
+
* @param description Description of the resource (optional)
|
|
306
|
+
* @param mimeType MIME type of the resource content (optional)
|
|
307
|
+
* @param title Human-readable title for the resource (optional)
|
|
308
|
+
*/
|
|
309
|
+
constructor(uri: string, name: string, description?: string | undefined, mimeType?: string | undefined, title?: string | undefined);
|
|
310
|
+
}
|