Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added enhanced adapter license info to schema and types #2591

Merged
merged 6 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/types-dev/objects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,28 @@ declare global {
ignoreInVersions: number[];
}

type PaidLicenseType = 'paid' | 'commercial' | 'limited';

interface LicenseInformationFree {
/** License of the software */
license?: string;
/** Use 'paid' for adapters which do not work without a paid license. Use 'commercial' for adapters which require a license for commercial use only. Use 'limited' if some functionalities are not available without a paid license. */
type: 'free';
/** Hyperlink, where information about the license can be found. This is required if the license type is different from 'free'. */
link?: string;
}

interface LicenseInformationWithPayment {
/** License of the software */
license?: string;
/** Use 'paid' for adapters which do not work without a paid license. Use 'commercial' for adapters which require a license for commercial use only. Use 'limited' if some functionalities are not available without a paid license. */
type: PaidLicenseType;
/** Hyperlink, where information about the license can be found. This is required if the license type is different from 'free'. */
link: string;
}

type LicenseInformation = LicenseInformationFree | LicenseInformationWithPayment;

interface AdapterCommon extends ObjectCommon {
/** Custom attributes to be shown in admin in the object browser */
adminColumns?: any[];
Expand Down Expand Up @@ -649,6 +671,8 @@ declare global {
/** A list of pages that should be shown on the ioBroker cloud index page */
welcomeScreenPro?: WelcomeScreenEntry[];
wwwDontUpload?: boolean;
/** License, can be legacy string with type of software license or an object representing information more license details */
license?: string | LicenseInformation;

// Make it possible to narrow the object type using the custom property
custom?: undefined;
Expand Down
8 changes: 8 additions & 0 deletions packages/types-public/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,14 @@ const _adapterObject: ioBroker.AdapterObject = {
objects: []
};

if (typeof _adapterObject.common.license === 'object' && _adapterObject.common.license.type === 'paid') {
// for non-free licenses link is non optional
_adapterObject.common.license.link.includes('https://');
} else {
// @ts-expect-error
_adapterObject.common.license.link.includes('https://');
}

const _folderObject: ioBroker.FolderObject = {
_id: '',
type: 'folder',
Expand Down
Loading
Loading