Skip to content

Commit

Permalink
Extension of localLinks structure in io-package.json (#2844)
Browse files Browse the repository at this point in the history
* Extension of localLinks structure in io-package.json

* Extension of localLinks structure in io-package.json

* Extension of localLinks structure in io-package.json

* Extension of localLinks structure in io-package.json

* Extension of localLinks structure in io-package.json

* do not merge visWidgets and localLinks

* Update schemas/io-package.json

Co-authored-by: Max Hauser <[email protected]>

* Added comments and removed deprecationMessages

* added test

* format

---------

Co-authored-by: Max Hauser <[email protected]>
  • Loading branch information
GermanBluefox and foxriver76 authored Jul 20, 2024
1 parent 12a17e8 commit 0e3f4a4
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 16 deletions.
9 changes: 8 additions & 1 deletion packages/cli/src/lib/setup/setupUpload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Upload adapter files into DB
*
* Copyright 2013-2023 bluefox <[email protected]>
* Copyright 2013-2024 bluefox <[email protected]>
*
* MIT License
*
Expand Down Expand Up @@ -744,12 +744,19 @@ export class Upload {
newObject.common.installedVersion = ioPack.common.version;
newObject.common.installedFrom = ioPack.common.installedFrom;

// do not merge visWidgets and localLinks
if (ioPack.common.visWidgets) {
newObject.common.visWidgets = ioPack.common.visWidgets;
} else {
delete newObject.common.visWidgets;
}

if (ioPack.common.localLinks) {
newObject.common.localLinks = ioPack.common.localLinks;
} else {
delete newObject.common.localLinks;
}

if (!ioPack.common.compact && newObject.common.compact) {
newObject.common.compact = ioPack.common.compact;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/types-dev/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface DatabaseBackupOptions {
/** by default backup every 2 hours. Time is in minutes. To disable backup set the value to 0 */
period: number;
'// period': string;
/** Absolute path to backup directory or empty to backup in data directory */
/** Absolute path to back-up directory or empty to back-up in data directory */
path: string;
'// path': string;
}
Expand All @@ -33,15 +33,15 @@ interface JsonlOptions {
'// throttleFS (1)': string;
'// throttleFS (2)': string;
/**
* By default, the database immediately writes to the database file. Write accesses can be reduced using the throttleFS option.
* By default, the database immediately writes to the database file. Write access can be reduced using the throttleFS option.
* Be aware that buffered changes will be lost in case the process crashes
*/
throttleFS: {
'// intervalMs': string;
/** Write to the database file no more than every intervalMs milliseconds. */
intervalMs: number;
'// maxBufferedCommands': string;
/** Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash. */
/** Force writing of buffered commands after so many changes. This reduces memory consumption and data loss in case of a crash. */
maxBufferedCommands: number;
};
}
Expand Down
37 changes: 29 additions & 8 deletions packages/types-dev/objects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,27 @@ declare global {

type ConnectionType = 'local' | 'cloud';

type LocalLink = {
/** Link to the web service of this adapter, like: "%web_protocol%://%ip%:%web_port%/vis-2/edit.html" */
link: string;
/** Name of the link. Could be multi-language */
name?: ioBroker.StringOrTranslated;
/** Color */
color?: string;
/** Link to icon, like "vis-2/img/favicon.png" */
icon?: string;
/** Link to the adapter if it could be shown in the free cloud, like: vis-2/index.html according to "https://iobroker.net/" */
cloud?: string;
/** Link to the adapter if it could be shown in the pro-cloud, like: vis-2/edit.html according to "https://iobroker.pro/" */
pro?: string;
/** If this link should be shown on the intro tab in admin. false = do not show */
intro?: boolean;
/** Order of the card. Used on "intro" and cloud tabs to sort the links */
order?: number;
/** Description of the link. Could be multi-language */
description?: ioBroker.StringOrTranslated;
};

interface AdapterCommon extends ObjectCommon {
/** Custom attributes to be shown in admin in the object browser */
adminColumns?: string | (string | CustomAdminColumn)[];
Expand Down Expand Up @@ -604,7 +625,7 @@ declare global {
blockly?: boolean;
/** Where the adapter will get its data from. Set this together with @see dataSource */
connectionType?: ConnectionType;
/** If true, this adapter can be started in compact mode (in the same process as other adpaters) */
/** If true, this adapter can be started in compact mode (in the same process as other adapters) */
compact?: boolean;
/** The directory relative to iobroker-data where the adapter stores the data. Supports the placeholder `%INSTANCE%`. This folder will be backed up and restored automatically. */
dataFolder?: string;
Expand All @@ -626,25 +647,25 @@ declare global {
getHistory?: boolean;
/** Filename of the local icon which is shown for installed adapters. Should be located in the `admin` directory */
icon?: string;
/** The adapter will be executed once additionally after installation and the `install` event will be emitted during this run. This allows for executing one time installation code. */
/** The adapter will be executed once additionally after installation, and the `install` event will be emitted during this run. This allows for executing one time installation code. */
install?: boolean;
/** Source, where this adapter has been installed from, to enable reinstalling on e.g., backup restore */
installedFrom?: InstalledFrom;
/** Which version of this adapter is installed */
installedVersion: string;
keywords?: string[];
/** A dictionary of links to web services this adapter provides */
localLinks?: Record<string, string>;
localLinks?: Record<string, string | LocalLink>;
/** @deprecated Use @see localLinks */
localLink?: string;
loglevel?: LogLevel;
/** Whether this adapter receives logs from other hosts and adapters (e.g., to strore them somewhere) */
/** Whether this adapter receives logs from other hosts and adapters (e.g., to store them somewhere) */
logTransporter?: boolean;
/** Path to the start file of the adapter. Should be the same as in `package.json` */
main?: string;
/** Whether the admin tab is written in materialize style. Required for Admin 3+ */
/** Whether the admin tab is written in materialized style. Required for Admin 3+ */
materializeTab?: boolean;
/** Whether the admin configuration dialog is written in materialize style. Required for Admin 3+ */
/** Whether the admin configuration dialog is written in materialized style. Required for Admin 3+ */
materialize: boolean;
/** @deprecated Use @see supportedMessages up from controller v5 */
messagebox?: true;
Expand Down Expand Up @@ -720,9 +741,9 @@ declare global {
webExtension?: string;
webPreSettings?: any; // ?
webservers?: any; // ?
/** A list of pages that should be shown on the "web" index page */
/** @deprecated (use localLinks) A list of pages that should be shown on the "web" index page */
welcomeScreen?: WelcomeScreenEntry[];
/** A list of pages that should be shown on the ioBroker cloud index page */
/** @deprecated (use localLinks) A list of pages that should be shown on the ioBroker cloud index page */
welcomeScreenPro?: WelcomeScreenEntry[];
wwwDontUpload?: boolean;
/** @deprecated Use 'common.licenseInformation' instead */
Expand Down
7 changes: 7 additions & 0 deletions packages/types-public/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,13 @@ const _adapterObject: ioBroker.AdapterObject = {
name: 'test',
automaticUpgrade: 'minor',
platform: 'Javascript/Node.js',
localLinks: {
link1: '%web_protocol%://%ip%:%web_port%/vis-2/edit.html',
link2: {
name: { en: 'Service' },
link: '%web_protocol%://%ip%:%web_port%/vis-2/edit.html'
}
},
supportedMessages: {
deviceManager: true
},
Expand Down
54 changes: 50 additions & 4 deletions schemas/io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1179,21 +1179,67 @@
".+": {
"anyOf": [
{
"type": "string"
"type": "string",
"description": "DEPRECATED: Please use structure {link, color, pro, cloud, intro, icon, name, order} instead of string"
},
{
"properties": {
"link": {
"type": "string"
"type": "string",
"description": "Link to the web service of this adapter, like: %web_protocol%://%ip%:%web_port%/vis-2/edit.html"
},
"color": {
"type": "string"
},
"pro": {
"anyOf": [
{
"type": "boolean",
"description": "DEPRECATED: Please use link template as string instead of boolean"
},
{
"description": "Link to the adapter, like: vis-2/index.html according to \"https://iobroker.pro/\"",
"type": "string"
}
]
},
"cloud": {
"description": "Link to the adapter, like: vis-2/index.html according to \"https://iobroker.net/\"",
"type": "string"
},
"intro": {
"description": "If this link should be shown on the intro tab in admin",
"type": "boolean"
},
"icon": {
"description": "Link to icon, like \"vis-2/img/favicon.png\"",
"type": "string"
},
"name": {
"description": "Name of the link. Could be multi-language",
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/multilingual"
}
]
},
"order": {
"description": "Used on \"intro\" and cloud tabs to sort the links",
"type": "number"
},
"description": {
"description": "Description of the link. Could be multi-language",
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/definitions/multilingual"
}
]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1461,7 +1507,7 @@
}
},
"welcomeScreen": {
"description": "Array of pages, that should be shown on the \"web\" index.html page. [\"vis/edit.html\", \"vis/index.html\"] or [{\"link\": \"vis/edit.html\", \"name\": \"Vis editor\", \"img\": \"vis/img/edit.png\", \"color\": \"blue\"}, \"vis/index.html\"]",
"description": "DEPRECATED: Please use common.localLinks instead. Array of pages, that should be shown on the \"web\" index.html page. [\"vis/edit.html\", \"vis/index.html\"] or [{\"link\": \"vis/edit.html\", \"name\": \"Vis editor\", \"img\": \"vis/img/edit.png\", \"color\": \"blue\"}, \"vis/index.html\"]",
"type": "array",
"items": {
"type": [
Expand All @@ -1471,7 +1517,7 @@
}
},
"welcomeScreenPro": {
"description": "Array of pages used on access via ioBroker cloud, that should be shown on the \"web\" index.html page. [\"vis/edit.html\", \"vis/index.html\"] or [{\"link\": \"vis/edit.html\", \"name\": \"Vis editor\", \"img\": \"vis/img/edit.png\", \"color\": \"blue\"}, \"vis/index.html\"]",
"description": "DEPRECATED: Please use common.localLinks instead. Array of pages used on access via ioBroker cloud, that should be shown on the \"web\" index.html page. [\"vis/edit.html\", \"vis/index.html\"] or [{\"link\": \"vis/edit.html\", \"name\": \"Vis editor\", \"img\": \"vis/img/edit.png\", \"color\": \"blue\"}, \"vis/index.html\"]",
"type": "array",
"items": {
"type": [
Expand Down

0 comments on commit 0e3f4a4

Please sign in to comment.