@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/dist/models.js CHANGED
@@ -1,48 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IslandResponse = exports.IslandResponseConfig = exports.IslandConfig = exports.IslandAction = exports.IslandField = exports.Function = exports.AuthRequirement = exports.Parameter = exports.ParameterType = void 0;
3
+ exports.Resource = exports.Parameter = exports.IslandResponse = exports.IslandResponseConfig = exports.IslandConfig = exports.IslandField = exports.IslandAction = exports.Function = exports.AuthRequirement = exports.ParameterType = void 0;
4
4
  /**
5
5
  * Types of parameters supported by Opal tools
6
6
  */
7
7
  var ParameterType;
8
8
  (function (ParameterType) {
9
- ParameterType["String"] = "string";
10
- ParameterType["Integer"] = "integer";
11
- ParameterType["Number"] = "number";
12
9
  ParameterType["Boolean"] = "boolean";
13
- ParameterType["List"] = "array";
14
10
  ParameterType["Dictionary"] = "object";
11
+ ParameterType["Integer"] = "integer";
12
+ ParameterType["List"] = "array";
13
+ ParameterType["Number"] = "number";
14
+ ParameterType["String"] = "string";
15
15
  })(ParameterType || (exports.ParameterType = ParameterType = {}));
16
- /**
17
- * Parameter definition for an Opal tool
18
- */
19
- class Parameter {
20
- /**
21
- * Create a new parameter definition
22
- * @param name Parameter name
23
- * @param type Parameter type
24
- * @param description Parameter description
25
- * @param required Whether the parameter is required
26
- */
27
- constructor(name, type, description, required) {
28
- this.name = name;
29
- this.type = type;
30
- this.description = description;
31
- this.required = required;
32
- }
33
- /**
34
- * Convert to JSON for the discovery endpoint
35
- */
36
- toJSON() {
37
- return {
38
- name: this.name,
39
- type: this.type,
40
- description: this.description,
41
- required: this.required
42
- };
43
- }
44
- }
45
- exports.Parameter = Parameter;
46
16
  /**
47
17
  * Authentication requirements for an Opal tool
48
18
  */
@@ -64,8 +34,8 @@ class AuthRequirement {
64
34
  toJSON() {
65
35
  return {
66
36
  provider: this.provider,
37
+ required: this.required,
67
38
  scope_bundle: this.scopeBundle,
68
- required: this.required
69
39
  };
70
40
  }
71
41
  }
@@ -81,105 +51,111 @@ class Function {
81
51
  * @param parameters Function parameters
82
52
  * @param endpoint API endpoint
83
53
  * @param authRequirements Authentication requirements (optional)
54
+ * @param uiResource URI of associated UI resource for dynamic rendering (optional)
84
55
  */
85
- constructor(name, description, parameters, endpoint, authRequirements) {
56
+ constructor(name, description, parameters, endpoint, authRequirements, uiResource) {
86
57
  this.name = name;
87
58
  this.description = description;
88
59
  this.parameters = parameters;
89
60
  this.endpoint = endpoint;
90
61
  this.authRequirements = authRequirements;
62
+ this.uiResource = uiResource;
91
63
  /**
92
64
  * HTTP method for the endpoint (default: POST)
93
65
  */
94
- this.httpMethod = 'POST';
66
+ this.httpMethod = "POST";
95
67
  }
96
68
  /**
97
69
  * Convert to JSON for the discovery endpoint
98
70
  */
99
71
  toJSON() {
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
73
  const result = {
101
- name: this.name,
102
74
  description: this.description,
103
- parameters: this.parameters.map(p => p.toJSON()),
104
75
  endpoint: this.endpoint,
105
- http_method: this.httpMethod
76
+ http_method: this.httpMethod,
77
+ name: this.name,
78
+ parameters: this.parameters.map((p) => p.toJSON()),
106
79
  };
107
80
  if (this.authRequirements && this.authRequirements.length > 0) {
108
- result.auth_requirements = this.authRequirements.map(auth => auth.toJSON());
81
+ result.auth_requirements = this.authRequirements.map((auth) => auth.toJSON());
82
+ }
83
+ if (this.uiResource !== undefined) {
84
+ result.ui_resource = this.uiResource;
109
85
  }
110
86
  return result;
111
87
  }
112
88
  }
113
89
  exports.Function = Function;
114
90
  /**
115
- * Island field definition for interactive UI components
91
+ * Island action definition for interactive UI components
116
92
  */
117
- class IslandField {
93
+ class IslandAction {
118
94
  /**
119
- * Create a new island field
120
- * @param name Programmatic field identifier
121
- * @param label Human-readable label
122
- * @param type Field type
123
- * @param value Current field value
124
- * @param hidden Whether to hide from user
125
- * @param options Available options for selection
95
+ * Create a new island action
96
+ * @param name Programmatic action identifier
97
+ * @param label Human-readable button label
98
+ * @param type UI element type
99
+ * @param endpoint API endpoint to call
100
+ * @param operation Operation type
126
101
  */
127
- constructor(name, label, type, value = "", hidden = false, options = []) {
102
+ constructor(name, label, type, endpoint, operation = "create") {
128
103
  this.name = name;
129
104
  this.label = label;
130
105
  this.type = type;
131
- this.value = value;
132
- this.hidden = hidden;
133
- this.options = options;
106
+ this.endpoint = endpoint;
107
+ this.operation = operation;
134
108
  }
135
109
  /**
136
110
  * Convert to JSON for the discovery endpoint
137
111
  */
138
112
  toJSON() {
139
113
  return {
140
- name: this.name,
114
+ endpoint: this.endpoint,
141
115
  label: this.label,
116
+ name: this.name,
117
+ operation: this.operation,
142
118
  type: this.type,
143
- value: this.value,
144
- hidden: this.hidden,
145
- options: this.options,
146
119
  };
147
120
  }
148
121
  }
149
- exports.IslandField = IslandField;
122
+ exports.IslandAction = IslandAction;
150
123
  /**
151
- * Island action definition for interactive UI components
124
+ * Island field definition for interactive UI components
152
125
  */
153
- class IslandAction {
126
+ class IslandField {
154
127
  /**
155
- * Create a new island action
156
- * @param name Programmatic action identifier
157
- * @param label Human-readable button label
158
- * @param type UI element type
159
- * @param endpoint API endpoint to call
160
- * @param operation Operation type
128
+ * Create a new island field
129
+ * @param name Programmatic field identifier
130
+ * @param label Human-readable label
131
+ * @param type Field type
132
+ * @param value Current field value
133
+ * @param hidden Whether to hide from user
134
+ * @param options Available options for selection
161
135
  */
162
- constructor(name, label, type, endpoint, operation = "create") {
136
+ constructor(name, label, type, value = "", hidden = false, options = []) {
163
137
  this.name = name;
164
138
  this.label = label;
165
139
  this.type = type;
166
- this.endpoint = endpoint;
167
- this.operation = operation;
140
+ this.value = value;
141
+ this.hidden = hidden;
142
+ this.options = options;
168
143
  }
169
144
  /**
170
145
  * Convert to JSON for the discovery endpoint
171
146
  */
172
147
  toJSON() {
173
148
  return {
174
- name: this.name,
149
+ hidden: this.hidden,
175
150
  label: this.label,
151
+ name: this.name,
152
+ options: this.options,
176
153
  type: this.type,
177
- endpoint: this.endpoint,
178
- operation: this.operation,
154
+ value: this.value,
179
155
  };
180
156
  }
181
157
  }
182
- exports.IslandAction = IslandAction;
158
+ exports.IslandField = IslandField;
183
159
  /**
184
160
  * Island configuration for interactive UI components
185
161
  */
@@ -202,14 +178,14 @@ class IslandConfig {
202
178
  */
203
179
  toJSON() {
204
180
  return {
205
- fields: this.fields.map((field) => field.toJSON()),
206
181
  actions: this.actions.map((action) => action.toJSON()),
182
+ fields: this.fields.map((field) => field.toJSON()),
207
183
  };
208
184
  }
209
185
  }
210
186
  exports.IslandConfig = IslandConfig;
211
- IslandConfig.Field = IslandField;
212
187
  IslandConfig.Action = IslandAction;
188
+ IslandConfig.Field = IslandField;
213
189
  /**
214
190
  * Island response configuration
215
191
  */
@@ -265,3 +241,54 @@ class IslandResponse {
265
241
  }
266
242
  exports.IslandResponse = IslandResponse;
267
243
  IslandResponse.ResponseConfig = IslandResponseConfig;
244
+ /**
245
+ * Parameter definition for an Opal tool
246
+ */
247
+ class Parameter {
248
+ /**
249
+ * Create a new parameter definition
250
+ * @param name Parameter name
251
+ * @param type Parameter type
252
+ * @param description Parameter description
253
+ * @param required Whether the parameter is required
254
+ */
255
+ constructor(name, type, description, required) {
256
+ this.name = name;
257
+ this.type = type;
258
+ this.description = description;
259
+ this.required = required;
260
+ }
261
+ /**
262
+ * Convert to JSON for the discovery endpoint
263
+ */
264
+ toJSON() {
265
+ return {
266
+ description: this.description,
267
+ name: this.name,
268
+ required: this.required,
269
+ type: this.type,
270
+ };
271
+ }
272
+ }
273
+ exports.Parameter = Parameter;
274
+ /**
275
+ * Resource definition for MCP resources
276
+ */
277
+ class Resource {
278
+ /**
279
+ * Create a new resource definition
280
+ * @param uri The unique URI for this resource (e.g., "ui://my-app/create-form")
281
+ * @param name Name of the resource
282
+ * @param description Description of the resource (optional)
283
+ * @param mimeType MIME type of the resource content (optional)
284
+ * @param title Human-readable title for the resource (optional)
285
+ */
286
+ constructor(uri, name, description, mimeType, title) {
287
+ this.uri = uri;
288
+ this.name = name;
289
+ this.description = description;
290
+ this.mimeType = mimeType;
291
+ this.title = title;
292
+ }
293
+ }
294
+ exports.Resource = Resource;