Use ts-expect-error in platform code (#69883)

* ts-ignore --> ts-expect-error

* fix error with mutable array

* fix errors in consumers code

* update SOM

* fix FeatureConfig & Feature compatibility

* do not re-export from code. it breaks built version

* update docs

* add eslint rule for platform team code

* remove test. this is covered by ts-expect-error in unit tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2020-06-30 08:37:42 +03:00 committed by GitHub
parent 7144db201f
commit 159369b719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 134 additions and 286 deletions

View file

@ -49,7 +49,9 @@ export interface FeatureConfig {
* This does not restrict access to your feature based on license.
* Its only purpose is to inform the space and roles UIs on which features to display.
*/
validLicenses?: Array<'basic' | 'standard' | 'gold' | 'platinum' | 'enterprise' | 'trial'>;
validLicenses?: ReadonlyArray<
'basic' | 'standard' | 'gold' | 'platinum' | 'enterprise' | 'trial'
>;
/**
* An optional EUI Icon to be used when displaying your feature.
@ -66,7 +68,7 @@ export interface FeatureConfig {
* An array of app ids that are enabled when this feature is enabled.
* Apps specified here will automatically cascade to the privileges defined below, unless specified differently there.
*/
app: string[];
app: readonly string[];
/**
* If this feature includes management sections, you can specify them here to control visibility of those
@ -83,14 +85,14 @@ export interface FeatureConfig {
* ```
*/
management?: {
[sectionId: string]: string[];
[sectionId: string]: readonly string[];
};
/**
* If this feature includes a catalogue entry, you can specify them here to control visibility based on the current space.
*
* Items specified here will automatically cascade to the privileges defined below, unless specified differently there.
*/
catalogue?: string[];
catalogue?: readonly string[];
/**
* Feature privilege definition.
@ -112,7 +114,7 @@ export interface FeatureConfig {
/**
* Optional sub-feature privilege definitions. This can only be specified if `privileges` are are also defined.
*/
subFeatures?: SubFeatureConfig[];
subFeatures?: readonly SubFeatureConfig[];
/**
* Optional message to display on the Role Management screen when configuring permissions for this feature.
@ -124,7 +126,7 @@ export interface FeatureConfig {
*/
reserved?: {
description: string;
privileges: ReservedKibanaPrivilege[];
privileges: readonly ReservedKibanaPrivilege[];
};
}

View file

@ -26,13 +26,13 @@ export interface FeatureKibanaPrivileges {
* ```
*/
management?: {
[sectionId: string]: string[];
[sectionId: string]: readonly string[];
};
/**
* If this feature includes a catalogue entry, you can specify them here to control visibility based on user permissions.
*/
catalogue?: string[];
catalogue?: readonly string[];
/**
* If your feature includes server-side APIs, you can tag those routes to secure access based on user permissions.
@ -60,7 +60,7 @@ export interface FeatureKibanaPrivileges {
* A generic tag name like "access:read" could be used elsewhere, and access to that API endpoint would also
* extend to any routes you have also tagged with that name.
*/
api?: string[];
api?: readonly string[];
/**
* If your feature exposes a client-side application (most of them do!), then you can control access to them here.
@ -73,7 +73,7 @@ export interface FeatureKibanaPrivileges {
* ```
*
*/
app?: string[];
app?: readonly string[];
/**
* If your feature requires access to specific saved objects, then specify your access needs here.
@ -88,7 +88,7 @@ export interface FeatureKibanaPrivileges {
* }
* ```
*/
all: string[];
all: readonly string[];
/**
* List of saved object types which users should have read-only access to when granted this privilege.
@ -99,7 +99,7 @@ export interface FeatureKibanaPrivileges {
* }
* ```
*/
read: string[];
read: readonly string[];
};
/**
* A list of UI Capabilities that should be granted to users with this privilege.
@ -121,5 +121,5 @@ export interface FeatureKibanaPrivileges {
*
* @see UICapabilities
*/
ui: string[];
ui: readonly string[];
}

View file

@ -15,7 +15,7 @@ export interface SubFeatureConfig {
name: string;
/** Collection of privilege groups */
privilegeGroups: SubFeaturePrivilegeGroupConfig[];
privilegeGroups: readonly SubFeaturePrivilegeGroupConfig[];
}
/**
@ -45,7 +45,7 @@ export interface SubFeaturePrivilegeGroupConfig {
/**
* The privileges which belong to this group.
*/
privileges: SubFeaturePrivilegeConfig[];
privileges: readonly SubFeaturePrivilegeConfig[];
}
/**