@choiceopen/atomemo-plugin-schema 0.2.0 → 0.2.1

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