@iobroker/dm-utils 0.3.1 → 0.5.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
@@ -295,6 +295,12 @@ This method returns a promise that resolves to a `ProgressDialog` object.
295
295
  ### **WORK IN PROGRESS**
296
296
  -->
297
297
  ## Changelog
298
+ ### 0.5.0 (2024-08-30)
299
+ * (bluefox) Migrated to eslint 9
300
+
301
+ ### 0.4.0 (2024-08-30)
302
+ * (bluefox) Added `state` type for JSON config
303
+
298
304
  ### 0.3.1 (2024-07-18)
299
305
  * (bluefox) Added qrCode type for JSON config
300
306
 
@@ -30,7 +30,7 @@ interface ObjectBrowserCustomFilter {
30
30
  };
31
31
  }
32
32
  export type ObjectBrowserType = 'state' | 'instance' | 'channel' | 'device' | 'chart';
33
- export type ConfigItemType = 'tabs' | 'panel' | 'text' | 'number' | 'color' | 'checkbox' | 'slider' | 'ip' | 'user' | 'room' | 'func' | 'select' | 'autocomplete' | 'image' | 'objectId' | 'password' | 'instance' | 'chips' | 'alive' | 'pattern' | 'sendto' | 'setState' | 'staticText' | 'staticLink' | 'staticImage' | 'table' | 'accordion' | 'jsonEditor' | 'language' | 'certificate' | 'certificates' | 'certCollection' | 'custom' | 'datePicker' | 'timePicker' | 'divider' | 'header' | 'cron' | 'fileSelector' | 'file' | 'imageSendTo' | 'selectSendTo' | 'autocompleteSendTo' | 'textSendTo' | 'coordinates' | 'interface' | 'license' | 'checkLicense' | 'uuid' | 'port' | 'deviceManager' | 'topic' | 'qrCode';
33
+ export type ConfigItemType = 'tabs' | 'panel' | 'text' | 'number' | 'color' | 'checkbox' | 'slider' | 'ip' | 'user' | 'room' | 'func' | 'select' | 'autocomplete' | 'image' | 'objectId' | 'password' | 'instance' | 'chips' | 'alive' | 'pattern' | 'sendto' | 'setState' | 'staticText' | 'staticLink' | 'staticImage' | 'table' | 'accordion' | 'jsonEditor' | 'language' | 'certificate' | 'certificates' | 'certCollection' | 'custom' | 'datePicker' | 'timePicker' | 'divider' | 'header' | 'cron' | 'fileSelector' | 'file' | 'imageSendTo' | 'selectSendTo' | 'autocompleteSendTo' | 'textSendTo' | 'coordinates' | 'interface' | 'license' | 'checkLicense' | 'uuid' | 'port' | 'deviceManager' | 'topic' | 'qrCode' | 'state';
34
34
  type ConfigIconType = 'edit' | 'auth' | 'send' | 'web' | 'warning' | 'error' | 'info' | 'search' | 'book' | 'help' | 'upload' | 'user' | 'group' | 'delete' | 'refresh' | 'add' | 'unpair' | 'pair' | string;
35
35
  export interface ConfigItemConfirmData {
36
36
  condition: string;
@@ -102,54 +102,84 @@ interface ConfigItemTableIndexed extends ConfigItem {
102
102
  }
103
103
  export interface ConfigItemAlive extends ConfigItem {
104
104
  type: 'alive';
105
+ /** check if the instance is alive. If not defined, it will be used current instance. You can use `${data.number}` pattern in the text. */
105
106
  instance?: string;
107
+ /** default text is `Instance %s is alive`, where %s will be replaced by `ADAPTER.0`. The translation must exist in i18n files. */
106
108
  textAlive?: string;
109
+ /** default text is `Instance %s is not alive`, where %s will be replaced by `ADAPTER.0`. The translation must exist in i18n files. */
107
110
  textNotAlive?: string;
108
111
  }
109
112
  export interface ConfigItemSelectOption {
113
+ /** Label of option */
110
114
  label: ioBroker.StringOrTranslated;
115
+ /** Value of option */
111
116
  value: number | string;
117
+ /** Formula or boolean value to show or hide the option */
112
118
  hidden?: string | boolean;
113
119
  }
114
120
  export interface ConfigItemPanel extends ConfigItem {
115
121
  type: 'panel' | never;
122
+ /** Label of tab */
116
123
  label?: ioBroker.StringOrTranslated;
117
124
  items: Record<string, ConfigItemAny>;
125
+ /** only possible as not part of tabs */
118
126
  collapsable?: boolean;
127
+ /** color of collapsable header `primary` or `secondary` or nothing */
119
128
  color?: 'primary' | 'secondary';
129
+ /** CSS Styles in React format (`marginLeft` and not `margin-left`) for the Panel component */
120
130
  innerStyle?: CustomCSSProperties;
131
+ /** i18n definitions: true - load from a file, string - name of subdirectory, object - translations */
121
132
  i18n?: boolean | string | Record<string, Record<ioBroker.Languages, string>>;
122
133
  }
123
134
  export interface ConfigItemPattern extends ConfigItem {
124
135
  type: 'pattern';
136
+ /** if true - show copy button */
125
137
  copyToClipboard?: boolean;
138
+ /** pattern like 'https://${data.ip}:${data.port}' */
126
139
  pattern: string;
127
140
  }
128
141
  export interface ConfigItemChip extends ConfigItem {
129
142
  type: 'chips';
143
+ /** if it is defined, so the option will be stored as string with delimiter instead of an array. E.g., by `delimiter=;` you will get `a;b;c` instead of `['a', 'b', 'c']` */
130
144
  delimiter?: string;
131
- pattern: string;
132
145
  }
133
146
  export interface ConfigItemTabs extends ConfigItem {
134
147
  type: 'tabs';
148
+ /** Object with panels `{"tab1": {}, "tab2": {}...}` */
135
149
  items: Record<string, ConfigItemPanel>;
150
+ /** `bottom`, `end`, `start` or `top`. Only for panels that has `icon` attribute. Default: `start` */
136
151
  iconPosition?: 'bottom' | 'end' | 'start' | 'top';
152
+ /** CSS Styles in React format (`marginLeft` and not `margin-left`) for the Mui-Tabs component */
137
153
  tabsStyle?: CustomCSSProperties;
154
+ /** i18n definitions: true - load from a file, string - name of subdirectory, object - translations */
138
155
  i18n?: boolean | string | Record<string, Record<ioBroker.Languages, string>>;
139
156
  }
140
157
  export interface ConfigItemText extends ConfigItem {
141
158
  type: 'text';
159
+ /** max length of the text in field */
142
160
  maxLength?: number;
143
161
  /** @deprecated use maxLength */
144
162
  max?: number;
163
+ /** read-only field */
145
164
  readOnly?: boolean;
165
+ /** default is true. Set this attribute to `false` if trim is not desired. */
146
166
  trim?: boolean;
167
+ /** default is 1. Set this attribute to `2` or more if you want to have a textarea with more than one row. */
147
168
  minRows?: number;
169
+ /** max rows of textarea. Used only if `minRows` > 1. */
148
170
  maxRows?: number;
171
+ /** if true, the clear button will not be shown */
149
172
  noClearButton?: boolean;
173
+ /** if true, the text will be validated as JSON */
174
+ validateJson?: boolean;
175
+ /** if true, the JSON will be validated only if the value is not empty */
176
+ allowEmpty?: boolean;
177
+ /** the value is time in ms or a string. Used only with readOnly flag */
178
+ time?: boolean;
150
179
  }
151
180
  export interface ConfigItemColor extends ConfigItem {
152
181
  type: 'color';
182
+ /** if true, the clear button will not be shown */
153
183
  noClearButton?: boolean;
154
184
  }
155
185
  export interface ConfigItemCheckbox extends ConfigItem {
@@ -181,6 +211,8 @@ export interface ConfigItemPassword extends ConfigItem {
181
211
  repeat?: boolean;
182
212
  /** true if allow viewing the password by toggling the view button (only for a new password while entering) */
183
213
  visible?: boolean;
214
+ /** The read-only flag. Visible is automatically true if readOnly is true */
215
+ readOnly?: boolean;
184
216
  /** max length of the text in field */
185
217
  maxLength?: number;
186
218
  /** @deprecated use maxLength */
@@ -228,6 +260,7 @@ export interface ConfigItemSlider extends ConfigItem {
228
260
  }
229
261
  export interface ConfigItemTopic extends ConfigItem {
230
262
  type: 'topic';
263
+ /** max length of the text in field */
231
264
  maxLength?: number;
232
265
  /** @deprecated use maxLength */
233
266
  max?: number;
@@ -270,6 +303,10 @@ export interface ConfigItemStaticText extends Omit<ConfigItem, 'button'> {
270
303
  label?: ioBroker.StringOrTranslated;
271
304
  /** link. Link could be dynamic like `#tab-objects/customs/${data.parentId} */
272
305
  href?: string;
306
+ /** target of the link: _self, _blank or window name. For relative links default is _self and for absolute - _blank */
307
+ target?: string;
308
+ /** If the GUI should be closed after a link was opened (only if the target is equal to '_self') */
309
+ close?: boolean;
273
310
  /** show a link as button */
274
311
  button?: boolean;
275
312
  /** type of button (`outlined`, `contained`, `text`) */
@@ -278,6 +315,8 @@ export interface ConfigItemStaticText extends Omit<ConfigItem, 'button'> {
278
315
  color?: 'primary' | 'secondary' | 'grey';
279
316
  /** if icon should be shown: `auth`, `send`, `web`, `warning`, `error`, `info`, `search`, `book`, `help`, `upload`. You can use `base64` icons (it starts with `data:image/svg+xml;base64,...`) or `jpg/png` images (ends with `.png`) . (Request via issue if you need more icons) */
280
317
  icon?: ConfigIconType;
318
+ /** styles for the button */
319
+ controlStyle: CustomCSSProperties;
281
320
  }
282
321
  export interface ConfigItemRoom extends ConfigItem {
283
322
  type: 'room';
@@ -293,7 +332,7 @@ export interface ConfigItemSelect extends ConfigItem {
293
332
  type: 'select';
294
333
  /** `[{label: {en: "option 1"}, value: 1}, ...]` or
295
334
  `[{"items": [{"label": "Val1", "value": 1}, {"label": "Val2", value: "2}], "name": "group1"}, {"items": [{"label": "Val3", "value": 3}, {"label": "Val4", value: "4}], "name": "group2"}, {"label": "Val5", "value": 5}]`
296
- */
335
+ */
297
336
  options: (ConfigItemSelectOption | {
298
337
  items: ConfigItemSelectOption[];
299
338
  label: ioBroker.StringOrTranslated;
@@ -331,6 +370,7 @@ export interface ConfigItemAutocompleteSendTo extends Omit<ConfigItem, 'data'> {
331
370
  options?: (string | ConfigItemSelectOption)[];
332
371
  data?: Record<string, any>;
333
372
  freeSolo?: boolean;
373
+ /** max length of the text in field */
334
374
  maxLength?: number;
335
375
  /** @deprecated use maxLength */
336
376
  max?: string;
@@ -338,9 +378,13 @@ export interface ConfigItemAutocompleteSendTo extends Omit<ConfigItem, 'data'> {
338
378
  }
339
379
  export interface ConfigItemAccordion extends ConfigItem {
340
380
  type: 'accordion';
381
+ /** Title shown on the accordion */
341
382
  titleAttr?: string;
383
+ /** If delete or add disabled, If noDelete is false, add, delete and move up/down should work */
342
384
  noDelete?: boolean;
385
+ /** If clone button should be shown. If true, the clone button will be shown. If attribute name, this name will be unique. */
343
386
  clone?: boolean | string;
387
+ /** Items of accordion */
344
388
  items: ConfigItemIndexed[];
345
389
  }
346
390
  export interface ConfigItemDivider extends ConfigItem {
@@ -355,12 +399,19 @@ export interface ConfigItemHeader extends ConfigItem {
355
399
  }
356
400
  export interface ConfigItemCoordinates extends ConfigItem {
357
401
  type: 'coordinates';
402
+ /** divider between latitude and longitude. Default "," (Used if longitudeName and latitudeName are not defined) */
358
403
  divider?: string;
404
+ /** init field with current coordinates if empty */
359
405
  autoInit?: boolean;
406
+ /** if defined, the longitude will be stored in this attribute, divider will be ignored */
360
407
  longitudeName?: string;
408
+ /** if defined, the latitude will be stored in this attribute, divider will be ignored */
361
409
  latitudeName?: string;
410
+ /** if defined, the checkbox with "Use system settings" will be shown and latitude, longitude will be read from system.config, a boolean will be saved to the given name */
362
411
  useSystemName?: string;
412
+ /** max length of the text in field */
363
413
  maxLength?: number;
414
+ /** @deprecated use maxLength */
364
415
  max?: number;
365
416
  }
366
417
  export interface ConfigItemCustom extends ConfigItem {
@@ -376,6 +427,7 @@ export interface ConfigItemCustom extends ConfigItem {
376
427
  }
377
428
  export interface ConfigItemDatePicker extends ConfigItem {
378
429
  type: 'datePicker';
430
+ /** max length of the text in field */
379
431
  maxLength?: number;
380
432
  /** @deprecated use maxLength */
381
433
  max?: number;
@@ -421,44 +473,105 @@ export interface ConfigItemSendTo extends Omit<ConfigItem, 'data'> {
421
473
  /** button tooltip */
422
474
  title?: ioBroker.StringOrTranslated;
423
475
  alsoDependsOn?: string[];
424
- container?: 'text' | 'div';
476
+ container?: 'text' | 'div' | 'html';
425
477
  copyToClipboard?: boolean;
478
+ /** Styles for button itself */
479
+ controlStyle?: CustomCSSProperties;
480
+ }
481
+ export interface ConfigItemState extends ConfigItem {
482
+ type: 'state';
483
+ /** Which object ID should be taken for the controlling. The ID is without "adapter.X." prefix */
484
+ oid: string;
485
+ /** If true, the state will be taken from system.adapter.XX.I. and not from XX.I */
486
+ system?: boolean;
487
+ /** How the value of the state should be shown */
488
+ control?: 'text' | 'html' | 'input' | 'slider' | 'select' | 'button' | 'switch' | 'number';
489
+ /** If true, the state will be shown as switch, select, button, slider or text input. Used only if no control property is defined */
490
+ controlled?: boolean;
491
+ /** Add unit to the value */
492
+ unit?: string;
493
+ /** this text will be shown if the value is true */
494
+ trueText?: string;
495
+ /** Style of the text if the value is true */
496
+ trueTextStyle?: CustomCSSProperties;
497
+ /** this text will be shown if the value is false or if the control is a "button" */
498
+ falseText?: string;
499
+ /** Style of the text if the value is false or if the control is a "button" */
500
+ falseTextStyle?: CustomCSSProperties;
501
+ /** This image will be shown if the value is true */
502
+ trueImage?: string;
503
+ /** This image will be shown if the value is false or if the control is a "button" */
504
+ falseImage?: string;
505
+ /** Minimum value for control type slider or number */
506
+ min?: number;
507
+ /** Maximum value for control type slider or number */
508
+ max?: number;
509
+ /** Step value for control type slider or number */
510
+ step?: number;
511
+ /** delay in ms for slider or number */
512
+ controlDelay?: number;
513
+ /** Variant of button */
514
+ variant?: 'contained' | 'outlined' | 'text';
426
515
  }
427
516
  export interface ConfigItemTextSendTo extends Omit<ConfigItem, 'data'> {
428
517
  type: 'textSendTo';
429
518
  container?: 'text' | 'div';
519
+ /** if true - show copy to clipboard button */
430
520
  copyToClipboard?: boolean;
521
+ /** by change of which attributes, the command must be resent */
431
522
  alsoDependsOn?: string[];
523
+ /** sendTo command */
432
524
  command?: string;
525
+ /** string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend */
433
526
  jsonData?: string;
527
+ /** object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined. */
434
528
  data?: Record<string, any>;
435
529
  }
436
530
  export interface ConfigItemSelectSendTo extends Omit<ConfigItem, 'data'> {
437
531
  type: 'selectSendTo';
532
+ /** allow manual editing. Without drop-down menu (if instance is offline). Default `true`. */
438
533
  manual?: boolean;
534
+ /** Multiple choice select */
439
535
  multiple?: boolean;
536
+ /** show item even if no label was found for it (by multiple), default=`true` */
440
537
  showAllValues?: boolean;
538
+ /** if true, the clear button will not be shown */
441
539
  noClearButton?: boolean;
540
+ /** sendTo command */
442
541
  command?: string;
542
+ /** string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend */
443
543
  jsonData?: string;
544
+ /** object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined. */
444
545
  data?: Record<string, any>;
546
+ /** by change of which attributes, the command must be resent */
445
547
  alsoDependsOn?: string[];
446
548
  }
447
549
  export interface ConfigItemTable extends ConfigItem {
448
550
  type: 'table';
449
551
  items?: ConfigItemTableIndexed[];
552
+ /** If delete or add disabled, If noDelete is false, add, delete and move up/down should work */
450
553
  noDelete?: boolean;
451
554
  /** @deprecated don't use */
452
555
  objKeyName?: string;
453
556
  /** @deprecated don't use */
454
557
  objValueName?: string;
558
+ /** If add allowed even if filter is set */
455
559
  allowAddByFilter?: boolean;
560
+ /** The number of lines from which the second add button at the bottom of the table will be shown. Default 5 */
456
561
  showSecondAddAt?: number;
562
+ /** Show first plus button on top of the first column and not on the left. */
457
563
  showFirstAddOnTop?: boolean;
564
+ /** If clone button should be shown. If true, the clone button will be shown. If attribute name, this name will be unique. */
458
565
  clone?: boolean | string;
566
+ /** If export button should be shown. Export as csv file. */
459
567
  export?: boolean;
568
+ /** If import button should be shown. Import from csv file. */
460
569
  import?: boolean;
570
+ /** Show table in compact mode */
571
+ compact?: boolean;
572
+ /** Specify the 'attr' name of columns which need to be unique */
461
573
  uniqueColumns?: string[];
574
+ /** These items will be encrypted before saving with simple (not SHA) encryption method */
462
575
  encryptedAttributes?: string[];
463
576
  }
464
577
  export interface ConfigItemTimePicker extends ConfigItem {
@@ -529,6 +642,10 @@ export interface ConfigItemUUID extends ConfigItem {
529
642
  }
530
643
  export interface ConfigItemJsonEditor extends ConfigItem {
531
644
  type: 'jsonEditor';
645
+ /** if false, the text will be not validated as JSON */
646
+ validateJson?: boolean;
647
+ /** if true, the JSON will be validated only if the value is not empty */
648
+ allowEmpty?: boolean;
532
649
  }
533
650
  export interface ConfigItemInterface extends ConfigItem {
534
651
  type: 'interface';
@@ -617,7 +734,7 @@ export interface ConfigItemFileSelector extends ConfigItem {
617
734
  /** Do not show the size of files */
618
735
  noSize?: boolean;
619
736
  }
620
- export type ConfigItemAny = ConfigItemAlive | ConfigItemAutocomplete | ConfigItemAutocompleteSendTo | ConfigItemPanel | ConfigItemTabs | ConfigItemText | ConfigItemNumber | ConfigItemColor | ConfigItemCheckbox | ConfigItemSlider | ConfigItemIP | ConfigItemUser | ConfigItemRoom | ConfigItemFunc | ConfigItemSelect | ConfigItemAccordion | ConfigItemCoordinates | ConfigItemDivider | ConfigItemHeader | ConfigItemCustom | ConfigItemDatePicker | ConfigItemDeviceManager | ConfigItemLanguage | ConfigItemPort | ConfigItemSendTo | ConfigItemTable | ConfigItemTimePicker | ConfigItemTextSendTo | ConfigItemSelectSendTo | ConfigItemCertCollection | ConfigItemCertificateSelect | ConfigItemCertificates | ConfigItemUUID | ConfigItemCheckLicense | ConfigItemPattern | ConfigItemChip | ConfigItemCRON | ConfigItemFile | ConfigItemFileSelector | ConfigItemImageSendTo | ConfigItemInstanceSelect | ConfigItemImageUpload | ConfigItemInterface | ConfigItemJsonEditor | ConfigItemLicense | ConfigItemPassword | ConfigItemSetState | ConfigItemStaticDivider | ConfigItemStaticHeader | ConfigItemStaticImage | ConfigItemStaticText | ConfigItemTopic | ConfigItemObjectId | ConfigItemQrCode;
737
+ export type ConfigItemAny = ConfigItemAlive | ConfigItemAutocomplete | ConfigItemAutocompleteSendTo | ConfigItemPanel | ConfigItemTabs | ConfigItemText | ConfigItemNumber | ConfigItemColor | ConfigItemCheckbox | ConfigItemSlider | ConfigItemIP | ConfigItemUser | ConfigItemRoom | ConfigItemFunc | ConfigItemSelect | ConfigItemAccordion | ConfigItemCoordinates | ConfigItemDivider | ConfigItemHeader | ConfigItemCustom | ConfigItemDatePicker | ConfigItemDeviceManager | ConfigItemLanguage | ConfigItemPort | ConfigItemSendTo | ConfigItemState | ConfigItemTable | ConfigItemTimePicker | ConfigItemTextSendTo | ConfigItemSelectSendTo | ConfigItemCertCollection | ConfigItemCertificateSelect | ConfigItemCertificates | ConfigItemUUID | ConfigItemCheckLicense | ConfigItemPattern | ConfigItemChip | ConfigItemCRON | ConfigItemFile | ConfigItemFileSelector | ConfigItemImageSendTo | ConfigItemInstanceSelect | ConfigItemImageUpload | ConfigItemInterface | ConfigItemJsonEditor | ConfigItemLicense | ConfigItemPassword | ConfigItemSetState | ConfigItemStaticDivider | ConfigItemStaticHeader | ConfigItemStaticImage | ConfigItemStaticText | ConfigItemTopic | ConfigItemObjectId | ConfigItemQrCode;
621
738
  export type JsonFormSchema = ConfigItemPanel;
622
739
  export type JsonFormData = Record<string, any>;
623
740
  export interface DeviceDetails {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/dm-utils",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "ioBroker Device Manager utilities for backend",
5
5
  "main": "build/index.js",
6
6
  "publishConfig": {
@@ -24,15 +24,15 @@
24
24
  "@iobroker/adapter-core": "^3.1.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@alcalzone/release-script": "^3.7.3",
27
+ "@alcalzone/release-script": "^3.8.0",
28
28
  "@alcalzone/release-script-plugin-license": "^3.7.0",
29
- "@types/node": "^20.14.11",
30
- "@typescript-eslint/eslint-plugin": "^7.16.1",
31
- "@typescript-eslint/parser": "^7.16.1",
32
- "eslint": "^8.57.0",
29
+ "@types/node": "^22.5.1",
30
+ "@typescript-eslint/eslint-plugin": "^8.3.0",
31
+ "@typescript-eslint/parser": "^8.3.0",
32
+ "eslint": "^9.9.1",
33
33
  "eslint-config-prettier": "^9.1.0",
34
34
  "prettier": "^3.3.3",
35
- "typescript": "^5.5.3"
35
+ "typescript": "^5.5.4"
36
36
  },
37
37
  "files": [
38
38
  "LICENSE",