-
Notifications
You must be signed in to change notification settings - Fork 8.2k
/
index.ts
62 lines (54 loc) · 1.53 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { SavedObject } from 'src/core/server';
import {
AssetType,
Installable,
Installation,
InstallationStatus,
KibanaAssetType,
} from '../../../../common/types/models/epm';
export {
getCategories,
getFile,
getInstallationObject,
getInstallation,
getPackageInfo,
getPackages,
SearchParams,
} from './get';
export { installKibanaAssets, installPackage, ensureInstalledPackage } from './install';
export { removeInstallation } from './remove';
type RequiredPackage = 'system' | 'endpoint';
const requiredPackages: Record<RequiredPackage, boolean> = {
system: true,
endpoint: true,
};
export function isRequiredPackage(value: string): value is RequiredPackage {
return value in requiredPackages;
}
export class PackageNotInstalledError extends Error {
constructor(pkgkey: string) {
super(`${pkgkey} is not installed`);
}
}
// only Kibana Assets use Saved Objects at this point
export const savedObjectTypes: AssetType[] = Object.values(KibanaAssetType);
export function createInstallableFrom<T>(
from: T,
savedObject?: SavedObject<Installation>
): Installable<T> {
return savedObject
? {
...from,
status: InstallationStatus.installed,
savedObject,
}
: {
...from,
status: InstallationStatus.notInstalled,
};
}