@choiceopen/atomemo-plugin-schema 0.1.8 → 0.2.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](./README.md) | [中文](./README.zh-CN.md)
4
4
 
5
- A comprehensive TypeScript type definitions and Zod schema validation library for developing Choiceform Atomemo plugins. This library ensures type safety at compile time and runtime validation for plugin definitions. Plugins must declare the implementation language via the `lang` field (currently `elixir` or `typescript`).
5
+ A comprehensive TypeScript type definitions and Zod schema validation library for developing Choiceform Atomemo plugins. This library ensures type safety at compile time and runtime validation for plugin definitions.
6
6
 
7
7
  ## Features
8
8
 
@@ -78,7 +78,6 @@ const pluginDefinition: PluginDefinition = {
78
78
  icon: 'https://example.com/icon.png',
79
79
  version: '1.0.0',
80
80
  locales: ['en', 'zh_CN'],
81
- lang: 'typescript',
82
81
  };
83
82
 
84
83
  // Validate at runtime
@@ -142,7 +141,7 @@ Each property type can be configured with different UI components:
142
141
  - `number-input`, `slider`
143
142
 
144
143
  **Boolean type components:**
145
- - `switch`
144
+ - `switch`, `checkbox`
146
145
 
147
146
  **Array type components:**
148
147
  - `multi-select`, `tag-input`, `key-value-editor`, `slider`, `array-section`
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](./README.md) | [中文](./README.zh-CN.md)
4
4
 
5
- 一个全面的 TypeScript 类型定义和 Zod Schema 验证库,用于开发 Choiceform Atomemo 插件。该库确保插件定义在编译时和运行时的类型安全与验证。插件需要通过 `lang` 字段声明实现语言(目前支持 `elixir` 与 `typescript`)。
5
+ 一个全面的 TypeScript 类型定义和 Zod Schema 验证库,用于开发 Choiceform Atomemo 插件。该库确保插件定义在编译时和运行时的类型安全与验证。
6
6
 
7
7
  ## 特性
8
8
 
@@ -78,7 +78,6 @@ const pluginDefinition: PluginDefinition = {
78
78
  icon: 'https://example.com/icon.png',
79
79
  version: '1.0.0',
80
80
  locales: ['en', 'zh_CN'],
81
- lang: 'typescript',
82
81
  };
83
82
 
84
83
  // 运行时验证
@@ -142,7 +141,7 @@ if (!result.success) {
142
141
  - `number-input`、`slider`
143
142
 
144
143
  **布尔类型可用组件:**
145
- - `switch`
144
+ - `switch`、`checkbox`
146
145
 
147
146
  **数组类型可用组件:**
148
147
  - `multi-select`、`tag-input`、`key-value-editor`、`slider`、`array-section`
@@ -108,24 +108,10 @@ interface PropertyUINumberInputProps extends PropertyUICommonProps {
108
108
  /** 代码编辑器 UI 属性 */
109
109
  interface PropertyUICodeEditorProps extends PropertyUICommonProps {
110
110
  component: "code-editor";
111
- language?: "json" | "javascript" | "python3";
112
- /**
113
- * Show line numbers in the code editor.
114
- * @default false
115
- */
111
+ language?: "json" | "javascript" | "python3" | "html";
116
112
  line_numbers?: boolean;
117
- /**
118
- * Enable line wrapping in the code editor.
119
- * @default false
120
- */
121
- line_wrapping?: boolean;
122
113
  max_height?: number;
123
114
  min_height?: number;
124
- /**
125
- * Number of rows to show in the code editor.
126
- * @default 4
127
- */
128
- rows?: number;
129
115
  }
130
116
  interface PropertyUISelectPropsBase {
131
117
  clearable?: boolean;
@@ -151,6 +137,9 @@ interface PropertyUIMultiSelectProps extends PropertyUICommonProps, PropertyUISe
151
137
  interface PropertyUISwitchProps extends PropertyUICommonProps {
152
138
  component: "switch";
153
139
  }
140
+ interface PropertyUICheckboxProps extends PropertyUICommonProps {
141
+ component: "checkbox";
142
+ }
154
143
  interface PropertyUISliderProps extends PropertyUICommonProps {
155
144
  component: "slider";
156
145
  marks?: Record<number, string>;
@@ -200,16 +189,13 @@ interface PropertyUICollapsiblePanelProps extends PropertyUICommonProps {
200
189
  remove_tooltip?: I18nText;
201
190
  sortable?: boolean;
202
191
  }
203
- interface PropertyUISectionProps extends PropertyUICommonProps {
204
- component: "section";
205
- }
206
- type PropertyUIProps = PropertyUIInputProps | PropertyUITextareaProps | PropertyUINumberInputProps | PropertyUICodeEditorProps | PropertyUISingleSelectProps | PropertyUIRadioGroupProps | PropertyUIEmojiPickerProps | PropertyUIColorPickerProps | PropertyUIMultiSelectProps | PropertyUISwitchProps | PropertyUISliderProps | PropertyUIKeyValueEditorProps | PropertyUITagInputProps | PropertyUICredentialSelectProps | PropertyUIJsonSchemaEditorProps | PropertyUIConditionsEditorProps | PropertyUIArraySectionProps | PropertyUICollapsiblePanelProps | PropertyUISectionProps | PropertyUIEncryptedInputProps;
192
+ type PropertyUIProps = PropertyUIInputProps | PropertyUITextareaProps | PropertyUINumberInputProps | PropertyUICodeEditorProps | PropertyUISingleSelectProps | PropertyUIRadioGroupProps | PropertyUIEmojiPickerProps | PropertyUIColorPickerProps | PropertyUIMultiSelectProps | PropertyUISwitchProps | PropertyUICheckboxProps | PropertyUISliderProps | PropertyUIKeyValueEditorProps | PropertyUITagInputProps | PropertyUICredentialSelectProps | PropertyUIJsonSchemaEditorProps | PropertyUIConditionsEditorProps | PropertyUIArraySectionProps | PropertyUICollapsiblePanelProps | PropertyUIEncryptedInputProps;
207
193
  type PropertyUIComponentType = PropertyUIProps["component"];
208
- type PropertyUIBoolean = PropertyUISwitchProps;
194
+ type PropertyUIBoolean = PropertyUISwitchProps | PropertyUICheckboxProps;
209
195
  type PropertyUINumber = PropertyUINumberInputProps | PropertyUISliderProps;
210
196
  type PropertyUIString = PropertyUIInputProps | PropertyUITextareaProps | PropertyUICodeEditorProps | PropertyUISingleSelectProps | PropertyUICredentialSelectProps | PropertyUIRadioGroupProps | PropertyUIEmojiPickerProps | PropertyUIColorPickerProps;
211
197
  type PropertyUIArray = PropertyUIMultiSelectProps | PropertyUITagInputProps | PropertyUIKeyValueEditorProps | PropertyUISliderProps | PropertyUIArraySectionProps;
212
- type PropertyUIContainer = PropertyUICollapsiblePanelProps | PropertyUISectionProps;
198
+ type PropertyUIContainer = PropertyUICollapsiblePanelProps;
213
199
  type PropertyUIMisc = PropertyUIJsonSchemaEditorProps | PropertyUIConditionsEditorProps;
214
200
  type PropertyUIObject = PropertyUIContainer | PropertyUIMisc | PropertyUICodeEditorProps;
215
201
  type PropertyUICredentialId = PropertyUICredentialSelectProps;
@@ -226,7 +212,8 @@ type DisplayCondition<TSchema extends JsonObject = JsonObject> =
226
212
  { [P in keyof TSchema]?: Condition<TSchema[P]> }
227
213
  /**
228
214
  * Logical operators for combining multiple conditions
229
- */ | RootFilter<TSchema>;
215
+ */
216
+ | RootFilter<TSchema>;
230
217
  /**
231
218
  * Root Filter Operators for group conditions
232
219
  */
@@ -234,15 +221,15 @@ interface RootFilter<TSchema extends JsonObject = JsonObject> {
234
221
  /**
235
222
  * Joins conditions with logical AND; all conditions must be true
236
223
  */
237
- $and?: Array<DisplayCondition<TSchema>> | null;
224
+ $and?: Array<DisplayCondition<TSchema>>;
238
225
  /**
239
226
  * Joins conditions with logical NOR; none of the conditions must be true
240
227
  */
241
- $nor?: Array<DisplayCondition<TSchema>> | null;
228
+ $nor?: Array<DisplayCondition<TSchema>>;
242
229
  /**
243
230
  * Joins conditions with logical OR; at least one condition must be true
244
231
  */
245
- $or?: Array<DisplayCondition<TSchema>> | null;
232
+ $or?: Array<DisplayCondition<TSchema>>;
246
233
  }
247
234
  type Condition<T extends JsonValue = JsonValue> = T | FilterOperators<T>;
248
235
  /**
@@ -253,55 +240,55 @@ interface FilterOperators<TValue extends JsonValue = JsonValue> {
253
240
  /**
254
241
  * Matches values equal to a specified value
255
242
  */
256
- $eq?: TValue | null;
243
+ $eq?: TValue;
257
244
  /**
258
245
  * Checks if a field exists
259
246
  */
260
- $exists?: boolean | null;
247
+ $exists?: boolean;
261
248
  /**
262
249
  * Matches values greater than a specified value
263
250
  */
264
- $gt?: TValue | null;
251
+ $gt?: TValue;
265
252
  /**
266
253
  * Matches values greater than or equal to a specified value
267
254
  */
268
- $gte?: TValue | null;
255
+ $gte?: TValue;
269
256
  /**
270
257
  * Matches any value specified in an array
271
258
  */
272
- $in?: Array<TValue> | null;
259
+ $in?: Array<TValue>;
273
260
  /**
274
261
  * Matches values less than a specified value
275
262
  */
276
- $lt?: TValue | null;
263
+ $lt?: TValue;
277
264
  /**
278
265
  * Matches values less than or equal to a specified value
279
266
  */
280
- $lte?: TValue | null;
267
+ $lte?: TValue;
281
268
  /**
282
269
  * Matches values based on a modulo operation; value: [divisor, remainder]
283
270
  */
284
- $mod?: TValue extends number ? [number, number] | null : never;
271
+ $mod?: TValue extends number ? [number, number] : never;
285
272
  /**
286
273
  * Matches values not equal to a specified value
287
274
  */
288
- $ne?: TValue | null;
275
+ $ne?: TValue;
289
276
  /**
290
277
  * Matches values not in a specified array
291
278
  */
292
- $nin?: Array<TValue> | null;
279
+ $nin?: Array<TValue>;
293
280
  /**
294
281
  * Regex options: i=case-insensitive, m=multiline, x=ignore whitespace, s=dotAll, u=unicode
295
282
  */
296
- $options?: TValue extends string ? string | null : never;
283
+ $options?: TValue extends string ? string : never;
297
284
  /**
298
285
  * Matches values against a regular expression pattern
299
286
  */
300
- $regex?: TValue extends string ? RegExp | string | null : never;
287
+ $regex?: TValue extends string ? RegExp | string : never;
301
288
  /**
302
289
  * Matches arrays with a specified number of elements
303
290
  */
304
- $size?: TValue extends Array<unknown> ? number | null : never;
291
+ $size?: TValue extends Array<unknown> ? number : never;
305
292
  }
306
293
  interface PropertyBase<TName extends string = string> {
307
294
  /**
@@ -311,92 +298,92 @@ interface PropertyBase<TName extends string = string> {
311
298
  /**
312
299
  * Display name (supports i18n)
313
300
  */
314
- display_name?: I18nText | null;
301
+ display_name?: I18nText;
315
302
  /**
316
303
  * Whether this property is required
317
304
  */
318
- required?: boolean | null;
305
+ required?: boolean;
319
306
  /**
320
307
  * Display condition; if not set, property is always visible
321
308
  */
322
309
  display?: {
323
- hide?: DisplayCondition | null;
324
- show?: DisplayCondition | null;
325
- } | null;
310
+ hide?: DisplayCondition;
311
+ show?: DisplayCondition;
312
+ };
326
313
  /**
327
314
  * AI-related configuration
328
315
  */
329
316
  ai?: {
330
- llm_description?: I18nText | null;
331
- } | null;
317
+ llm_description?: I18nText;
318
+ };
332
319
  /**
333
320
  * UI configuration for how the property is displayed
334
321
  */
335
- ui?: PropertyUICommonProps | null;
322
+ ui?: PropertyUICommonProps;
336
323
  }
337
324
  interface PropertyString<TName extends string = string> extends PropertyBase<TName> {
338
325
  type: "string";
339
326
  /**
340
327
  * Restrict value to a single constant
341
328
  */
342
- constant?: string | null;
329
+ constant?: string;
343
330
  /**
344
331
  * Default value when not specified
345
332
  */
346
- default?: string | null;
333
+ default?: string;
347
334
  /**
348
335
  * Restrict value to a set of allowed values
349
336
  */
350
- enum?: Array<string> | null;
337
+ enum?: Array<string>;
351
338
  /**
352
339
  * Maximum string length
353
340
  */
354
- max_length?: number | null;
341
+ max_length?: number;
355
342
  /**
356
343
  * Minimum string length
357
344
  */
358
- min_length?: number | null;
359
- ui?: PropertyUIString | null;
345
+ min_length?: number;
346
+ ui?: PropertyUIString;
360
347
  }
361
348
  interface PropertyNumber<TName extends string = string> extends PropertyBase<TName> {
362
349
  type: "number" | "integer";
363
350
  /**
364
351
  * Restrict value to a single constant
365
352
  */
366
- constant?: number | null;
353
+ constant?: number;
367
354
  /**
368
355
  * Default value when not specified
369
356
  */
370
- default?: number | null;
357
+ default?: number;
371
358
  /**
372
359
  * Restrict value to a set of allowed values
373
360
  */
374
- enum?: Array<number> | null;
361
+ enum?: Array<number>;
375
362
  /**
376
363
  * Maximum value (inclusive)
377
364
  */
378
- maximum?: number | null;
365
+ maximum?: number;
379
366
  /**
380
367
  * Minimum value (inclusive)
381
368
  */
382
- minimum?: number | null;
383
- ui?: PropertyUINumber | null;
369
+ minimum?: number;
370
+ ui?: PropertyUINumber;
384
371
  }
385
372
  interface PropertyBoolean<TName extends string = string> extends PropertyBase<TName> {
386
373
  type: "boolean";
387
374
  /**
388
375
  * Restrict value to a single constant
389
376
  */
390
- constant?: boolean | null;
377
+ constant?: boolean;
391
378
  /**
392
379
  * Default value when not specified
393
380
  */
394
- default?: boolean | null;
381
+ default?: boolean;
395
382
  /**
396
383
  * Restrict value to a set of allowed values
397
384
  */
398
- enum?: Array<boolean> | null;
399
- ui?: PropertyUIBoolean | null;
385
+ enum?: Array<boolean>;
386
+ ui?: PropertyUIBoolean;
400
387
  }
401
388
  /**
402
389
  * Object Property Type
@@ -415,22 +402,22 @@ interface PropertyObject<TName extends string = string, TDiscriminator extends s
415
402
  /**
416
403
  * Restrict value to a single constant
417
404
  */
418
- constant?: TValue | null;
405
+ constant?: TValue;
419
406
  /**
420
407
  * Default value when not specified
421
408
  */
422
- default?: TValue | null;
409
+ default?: TValue;
423
410
  /**
424
411
  * Restrict value to a set of allowed values
425
412
  */
426
- enum?: Array<TValue> | null;
413
+ enum?: Array<TValue>;
427
414
  /**
428
415
  * Schema for additional properties beyond those defined in `properties`.
429
416
  * Supports dynamic keys with values conforming to the specified property schema.
430
417
  * Semantics similar to JSON Schema's additionalProperties: https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#additionalProperties
431
418
  */
432
- additional_properties?: Property | null;
433
- ui?: PropertyUIObject | null;
419
+ additional_properties?: Property;
420
+ ui?: PropertyUIObject;
434
421
  }
435
422
  interface PropertyDiscriminatedUnion<TName extends string = string, TDiscriminator extends string = string> extends PropertyBase<TName> {
436
423
  type: "discriminated_union";
@@ -445,13 +432,13 @@ interface PropertyDiscriminatedUnion<TName extends string = string, TDiscriminat
445
432
  /**
446
433
  * UI component for displaying the discriminator field
447
434
  */
448
- discriminator_ui?: PropertyUISwitchProps | PropertyUISingleSelectProps | PropertyUIRadioGroupProps | null;
435
+ discriminator_ui?: PropertyUISwitchProps | PropertyUISingleSelectProps | PropertyUIRadioGroupProps;
449
436
  }
450
437
  interface PropertyArray<TName extends string = string> extends PropertyBase<TName> {
451
438
  type: "array";
452
- constant?: Array<JsonValue> | null;
453
- default?: Array<JsonValue> | null;
454
- enum?: Array<Array<JsonValue>> | null;
439
+ constant?: Array<JsonValue>;
440
+ default?: Array<JsonValue>;
441
+ enum?: Array<Array<JsonValue>>;
455
442
  /**
456
443
  * Item schema for array elements
457
444
  */
@@ -459,12 +446,12 @@ interface PropertyArray<TName extends string = string> extends PropertyBase<TNam
459
446
  /**
460
447
  * Maximum array size (inclusive)
461
448
  */
462
- max_items?: number | null;
449
+ max_items?: number;
463
450
  /**
464
451
  * Minimum array size (inclusive)
465
452
  */
466
- min_items?: number | null;
467
- ui?: PropertyUIArray | null;
453
+ min_items?: number;
454
+ ui?: PropertyUIArray;
468
455
  }
469
456
  interface PropertyCredentialId<TName extends string = string> extends PropertyBase<TName> {
470
457
  type: "credential_id";
@@ -474,11 +461,11 @@ interface PropertyCredentialId<TName extends string = string> extends PropertyBa
474
461
  * **Note:** The name must match exactly, otherwise the system will be unable to find the corresponding credential.
475
462
  */
476
463
  credential_name: string;
477
- ui?: PropertyUICredentialId | null;
464
+ ui?: PropertyUICredentialId;
478
465
  }
479
466
  interface PropertyEncryptedString<TName extends string = string> extends PropertyBase<TName> {
480
467
  type: "encrypted_string";
481
- ui?: PropertyUIEncryptedString | null;
468
+ ui?: PropertyUIEncryptedString;
482
469
  }
483
470
  type PropertyScalar<TName extends string = string> = PropertyString<TName> | PropertyBoolean<TName> | PropertyNumber<TName> | PropertyEncryptedString<TName>;
484
471
  type Property<TName extends string = string, TValue extends JsonValue = JsonValue> = PropertyScalar<TName> | PropertyCredentialId<TName> | PropertyArray<TName> | PropertyObject<TName, string, TValue extends JsonObject ? TValue : JsonObject> | PropertyDiscriminatedUnion<TName, string>;
@@ -513,15 +500,15 @@ interface PluginDefinition<Locales extends string[], TransporterOptions> extends
513
500
  /**
514
501
  * The author's name of the plugin.
515
502
  */
516
- author?: string | null;
503
+ author?: string;
517
504
  /**
518
505
  * The author's email address.
519
506
  */
520
- email?: string | null;
507
+ email?: string;
521
508
  /**
522
509
  * The source URL of the plugin.
523
510
  */
524
- repo?: string | null;
511
+ repo?: string;
525
512
  /**
526
513
  * The version of the plugin.
527
514
  *
@@ -529,21 +516,37 @@ interface PluginDefinition<Locales extends string[], TransporterOptions> extends
529
516
  *
530
517
  * We recommend doing it this way, but if you do provide this value, please ensure that it remains consistent with the version field in package.json.
531
518
  */
532
- version?: string | null;
519
+ version?: string;
533
520
  /**
534
521
  * The options for the transporter.
535
522
  */
536
523
  transporterOptions?: TransporterOptions;
537
- /**
538
- * The programming language the plugin is implemented in.
539
- */
540
- lang: "elixir" | "typescript";
541
524
  }
542
525
  type Feature = CredentialDefinition | DataSourceDefinition | ModelDefinition | ToolDefinition;
543
526
  /**
544
527
  * Credential definition
545
528
  */
546
529
  interface CredentialDefinition extends BaseDefinition {
530
+ authenticate: (input: {
531
+ args: {
532
+ parameters: {
533
+ /**
534
+ * If it is called for the LLM authentication, then this property is the model name.
535
+ */
536
+ model?: string;
537
+ [key: string]: unknown;
538
+ };
539
+ credentials: Record<string, string>;
540
+ };
541
+ }) => Promise<{
542
+ /**
543
+ * What kind of
544
+ */
545
+ adapter: "anthropic" | "openai" | "google" | "deepseek";
546
+ endpoint?: string;
547
+ model: string;
548
+ headers?: Record<string, string>;
549
+ }>;
547
550
  parameters: Array<PropertyScalar>;
548
551
  }
549
552
  /**
@@ -701,8 +704,11 @@ interface ToolDefinition extends BaseDefinition {
701
704
  *
702
705
  * **Caution for developers**: You must ensure that the return value is JSON serializable.
703
706
  */
704
- invoke: (context: {
705
- args: any;
707
+ invoke: (input: {
708
+ args: {
709
+ parameters: Record<string, any>;
710
+ credentials?: Record<string, string>;
711
+ };
706
712
  }) => Promise<JsonValue$1>;
707
713
  /**
708
714
  * Parameters
@@ -710,5 +716,5 @@ interface ToolDefinition extends BaseDefinition {
710
716
  parameters: Array<Property>;
711
717
  }
712
718
  //#endregion
713
- export { PropertyUIEmojiPickerProps as A, PropertyUIRadioGroupProps as B, PropertyUIBoolean as C, PropertyUIComponentType as D, PropertyUICommonProps as E, PropertyUIMisc as F, JsonValue$1 as G, PropertyUISingleSelectProps as H, PropertyUINumber as I, JsonValueSchema as K, PropertyUIObject as L, PropertyUIEncryptedString as M, PropertyUIInputProps as N, PropertyUIContainer as O, PropertyUIKeyValueEditorProps as P, PropertyUIOption as R, PropertyUIArraySectionProps as S, PropertyUIColorPickerProps as T, PropertyUIString as U, PropertyUISectionProps as V, PropertyUISwitchProps as W, PropertyNumber as _, ModelDefinition as a, PropertyString as b, DisplayCondition as c, PropertyArray as d, PropertyBase as f, PropertyEncryptedString as g, PropertyDiscriminatedUnion as h, Feature as i, PropertyUIEncryptedInputProps as j, PropertyUICredentialId as k, FilterOperators as l, PropertyCredentialId as m, CredentialDefinition as n, PluginDefinition as o, PropertyBoolean as p, I18nText as q, DataSourceDefinition as r, ToolDefinition as s, BaseDefinition as t, Property as u, PropertyObject as v, PropertyUICollapsiblePanelProps as w, PropertyUIArray as x, PropertyScalar as y, PropertyUIProps as z };
714
- //# sourceMappingURL=types-B3nkHte0.d.ts.map
719
+ export { PropertyUIEmojiPickerProps as A, PropertyUIRadioGroupProps as B, PropertyUIBoolean as C, PropertyUIComponentType as D, PropertyUICommonProps as E, PropertyUIMisc as F, JsonValueSchema as G, PropertyUIString as H, PropertyUINumber as I, I18nText as K, PropertyUIObject as L, PropertyUIEncryptedString as M, PropertyUIInputProps as N, PropertyUIContainer as O, PropertyUIKeyValueEditorProps as P, PropertyUIOption as R, PropertyUIArraySectionProps as S, PropertyUIColorPickerProps as T, PropertyUISwitchProps as U, PropertyUISingleSelectProps as V, JsonValue$1 as W, PropertyNumber as _, ModelDefinition as a, PropertyString as b, DisplayCondition as c, PropertyArray as d, PropertyBase as f, PropertyEncryptedString as g, PropertyDiscriminatedUnion as h, Feature as i, PropertyUIEncryptedInputProps as j, PropertyUICredentialId as k, FilterOperators as l, PropertyCredentialId as m, CredentialDefinition as n, PluginDefinition as o, PropertyBoolean as p, DataSourceDefinition as r, ToolDefinition as s, BaseDefinition as t, Property as u, PropertyObject as v, PropertyUICollapsiblePanelProps as w, PropertyUIArray as x, PropertyScalar as y, PropertyUIProps as z };
720
+ //# sourceMappingURL=definition-DEEuUiSF.d.mts.map