@gdacm/dashboard-manager 0.1.1

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.
@@ -0,0 +1,122 @@
1
+ import { GrafanaItem } from "@gdacm/grafana-items";
2
+ import { FolderInfo } from "./FolderInfo.js";
3
+ export type GenericMetaOptions = import("@gdacm/base-types").GenericMetaOptions;
4
+ export type DashboardMetaOptions = import("@gdacm/base-types").DashboardMetaOptions;
5
+ export type FolderInfoDefinition = FolderInfo | String;
6
+ /**
7
+ * @typedef {import("@gdacm/base-types").GenericMetaOptions} GenericMetaOptions
8
+ * @typedef {import("@gdacm/base-types").DashboardMetaOptions} DashboardMetaOptions
9
+ */
10
+ /**
11
+ * @typedef {FolderInfo|String} FolderInfoDefinition
12
+ */
13
+ export declare class DashboardInfo {
14
+ /** @type {string|undefined} */
15
+ _sid: string | undefined;
16
+ /** @type {string|undefined} */
17
+ _vid: string | undefined;
18
+ /** @type {string|undefined} */
19
+ _grafanaId: string | undefined;
20
+ /** @type {string|undefined} */
21
+ _title: string | undefined;
22
+ /** @type {string|undefined} */
23
+ _emoji: string | undefined;
24
+ /** @type {FolderInfoDefinition[]} */
25
+ _path: FolderInfoDefinition[];
26
+ /** @type {string[]} */
27
+ _tags: string[];
28
+ /**
29
+ * @type {GenericMetaOptions}
30
+ */
31
+ _metaOptions: GenericMetaOptions;
32
+ /** @type {((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>)|undefined} */
33
+ _dashboardGenerator: ((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>) | undefined;
34
+ constructor();
35
+ /**
36
+ * @returns {string|undefined}
37
+ */
38
+ get sid(): string | undefined;
39
+ /**
40
+ * @param {string} sid
41
+ * @returns {this}
42
+ */
43
+ setSid(sid: string): this;
44
+ /**
45
+ * @returns {string|undefined}
46
+ */
47
+ get vid(): string | undefined;
48
+ /**
49
+ * @param {string} vid
50
+ * @returns {this}
51
+ **/
52
+ setVid(vid: string): this;
53
+ /**
54
+ * @returns {string|undefined}
55
+ */
56
+ get grafanaId(): string | undefined;
57
+ /**
58
+ * @param {string} grafanaId
59
+ * @returns {this}
60
+ */
61
+ setGrafanaId(grafanaId: string): this;
62
+ /**
63
+ * @returns {string|undefined}
64
+ */
65
+ get title(): string | undefined;
66
+ /**
67
+ * @param {string} title
68
+ * @returns {this}
69
+ */
70
+ setTitle(title: string): this;
71
+ /**
72
+ * @returns {string|undefined}
73
+ */
74
+ get emoji(): string | undefined;
75
+ /**
76
+ * @param {string} emoji
77
+ * @returns {this}
78
+ */
79
+ setEmoji(emoji: string): this;
80
+ /**
81
+ * @returns {FolderInfoDefinition[]}
82
+ */
83
+ get path(): FolderInfoDefinition[];
84
+ /**
85
+ * @param {FolderInfoDefinition[]} path
86
+ * @returns {this}
87
+ */
88
+ setPath(path: FolderInfoDefinition[]): this;
89
+ /**
90
+ * @param {FolderInfoDefinition[]} path
91
+ * @returns {this}
92
+ */
93
+ injectIntoPath(path: FolderInfoDefinition[]): this;
94
+ /**
95
+ * @returns {string[]}
96
+ */
97
+ get tags(): string[];
98
+ /**
99
+ * @param {string[]} tags
100
+ * @returns {this}
101
+ */
102
+ setTags(tags: string[]): this;
103
+ /**
104
+ * @returns {GenericMetaOptions}
105
+ */
106
+ get metaOptions(): GenericMetaOptions;
107
+ /**
108
+ * @param {string} key
109
+ * @param {any} value
110
+ * @returns {this}
111
+ */
112
+ addMetaOption(key: string, value: any): this;
113
+ /**
114
+ * @returns {((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>)|undefined}
115
+ */
116
+ get getDashboard(): ((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>) | undefined;
117
+ /**
118
+ * @param {((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>)|undefined} dashboardGenerator
119
+ * @returns {this}
120
+ */
121
+ setDashboardGenerator(dashboardGenerator: ((uid: string, metaOption: DashboardMetaOptions) => Promise<GrafanaItem>) | undefined): this;
122
+ }
@@ -0,0 +1,51 @@
1
+ import { DashboardProject } from './DashboardProject.js';
2
+ import { DashboardsInfo } from './DashboardsInfo.js';
3
+ export type GenericMetaOptions = import("@gdacm/base-types").GenericMetaOptions;
4
+ export type DashboardMetaOptions = import("@gdacm/base-types").DashboardMetaOptions;
5
+ export type DashboardOptions = import("@gdacm/base-types").DashboardOptions;
6
+ export type DashboardGenerator = (uid: string, option: Object) => Promise<Object>;
7
+ /**
8
+ * @typedef {import("@gdacm/base-types").GenericMetaOptions} GenericMetaOptions
9
+ * @typedef {import("@gdacm/base-types").DashboardMetaOptions} DashboardMetaOptions
10
+ * @typedef {import("@gdacm/base-types").DashboardOptions} DashboardOptions
11
+ */
12
+ /**
13
+ * @typedef {(uid: String, option: Object) => Promise<Object>} DashboardGenerator
14
+ */
15
+ export declare class DashboardManager {
16
+ #private;
17
+ /**
18
+ * @type {{[projectName: string]: DashboardProject}}
19
+ */
20
+ dashboards: {
21
+ [projectName: string]: DashboardProject;
22
+ };
23
+ constructor();
24
+ /**
25
+ * @param {string} projectName
26
+ * @returns {DashboardProject} The project object
27
+ */
28
+ _ensureProjectExists(projectName: string): DashboardProject;
29
+ /**
30
+ * @param {string} projectName
31
+ * @param {DashboardsInfo} dashboardsInfo
32
+ * @returns {this}
33
+ */
34
+ registerDashboards(projectName: string, dashboardsInfo: DashboardsInfo): this;
35
+ /**
36
+ * @param {string} projectName
37
+ * @param {string} rootVid
38
+ * @param {string} rootGrafanaFolder
39
+ * @param {string|undefined} vidPrefix
40
+ * @param {GenericMetaOptions} metaOptions
41
+ * @returns {this}
42
+ */
43
+ setupProject(projectName: string, rootVid: string, rootGrafanaFolder: string, vidPrefix: string | undefined, metaOptions: GenericMetaOptions): this;
44
+ /**
45
+ * @param {string} projectName
46
+ * @param {string} rootFolderPath
47
+ * @param {GenericMetaOptions} [metaOptions] - Optional parameters for generating dashboards
48
+ * @returns {Promise<this>}
49
+ */
50
+ generateDashboards(projectName: string, rootFolderPath: string, metaOptions?: GenericMetaOptions): Promise<this>;
51
+ }
@@ -0,0 +1,83 @@
1
+ import { DashboardInfo } from "./DashboardInfo.js";
2
+ import { DashboardsInfo } from "./DashboardsInfo.js";
3
+ export type GenericMetaOptions = import("@gdacm/base-types").GenericMetaOptions;
4
+ export type DashboardProjectProperties = {
5
+ rootVid: string | undefined;
6
+ rootGrafanaFolder: string | undefined;
7
+ vidPrefix: string | undefined;
8
+ metaOptions: GenericMetaOptions;
9
+ };
10
+ /**
11
+ * @typedef {import("@gdacm/base-types").GenericMetaOptions} GenericMetaOptions
12
+ */
13
+ /**
14
+ * @typedef {{
15
+ * rootVid: String|undefined,
16
+ * rootGrafanaFolder: String|undefined,
17
+ * vidPrefix: String|undefined,
18
+ * metaOptions: GenericMetaOptions
19
+ * }} DashboardProjectProperties<T>
20
+ */
21
+ export declare class DashboardProject {
22
+ _name: string;
23
+ /**
24
+ * @type {DashboardProjectProperties}
25
+ */
26
+ _properties: DashboardProjectProperties;
27
+ /**
28
+ * @type {{[sid: String]: DashboardInfo}}
29
+ */
30
+ _dashboards: {
31
+ [sid: string]: DashboardInfo;
32
+ };
33
+ /**
34
+ * @type {DashboardsInfo[]}
35
+ */
36
+ _dashboardsCollection: DashboardsInfo[];
37
+ /**
38
+ * @param {String} name
39
+ */
40
+ constructor(name: string);
41
+ /**
42
+ * @param {DashboardInfo} dashboardInfo
43
+ */
44
+ addDashboardInfo(dashboardInfo: DashboardInfo): void;
45
+ /**
46
+ * @param {DashboardsInfo} dashboardsInfo
47
+ */
48
+ addDashboardsInfo(dashboardsInfo: DashboardsInfo): void;
49
+ /**
50
+ * @param {String} vid
51
+ */
52
+ setRootVid(vid: string): void;
53
+ /**
54
+ * @param {String} folder
55
+ */
56
+ setRootGrafanaFolder(folder: string): void;
57
+ /**
58
+ * @param {String} prefix
59
+ */
60
+ setVidPrefix(prefix: string): void;
61
+ /**
62
+ * @param {GenericMetaOptions} metaOptions
63
+ */
64
+ setMetaOptions(metaOptions: GenericMetaOptions): void;
65
+ get dashboards(): {
66
+ [sid: string]: DashboardInfo;
67
+ };
68
+ /**
69
+ * @param {Record<String, String|Number|Boolean|*>} info
70
+ * @returns {DashboardInfo[]}
71
+ */
72
+ getDashboards(info: Record<string, string | number | boolean | any>): DashboardInfo[];
73
+ get properties(): {
74
+ rootVid: string | undefined;
75
+ rootGrafanaFolder: string | undefined;
76
+ vidPrefix: string | undefined;
77
+ metaOptions: GenericMetaOptions;
78
+ };
79
+ get rootVid(): string | undefined;
80
+ get rootGrafanaFolder(): string | undefined;
81
+ get vidPrefix(): string | undefined;
82
+ get metaOptions(): import("@gdacm/base-types").GenericMetaOptions;
83
+ }
@@ -0,0 +1,34 @@
1
+ import { DashboardInfo } from "./DashboardInfo.js";
2
+ import { FolderInfo } from "./index.js";
3
+ export type DashboardsInfoItem = (DashboardInfo | DashboardsInfo | DashboardInfo[] | DashboardsInfo[] | ((info: Object) => DashboardInfo) | ((info: Object) => DashboardsInfo) | ((info: Object) => DashboardInfo[]) | ((info: Object) => DashboardsInfo[]));
4
+ /**
5
+ * @typedef {(DashboardInfo|DashboardsInfo|DashboardInfo[]|DashboardsInfo[]|((info: Object) => DashboardInfo)|((info: Object) => DashboardsInfo)|((info: Object) => DashboardInfo[])|((info: Object) => DashboardsInfo[]))} DashboardsInfoItem
6
+ */
7
+ export declare class DashboardsInfo {
8
+ /** @type {DashboardsInfoItem[]} */
9
+ _items: DashboardsInfoItem[];
10
+ /**
11
+ * @type {((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)[]}
12
+ */
13
+ _onDashboard: ((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)[];
14
+ /**
15
+ * @param {DashboardsInfoItem[]} items
16
+ */
17
+ constructor(...items: DashboardsInfoItem[]);
18
+ /**
19
+ * @param {Object} info
20
+ * @param {((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)[]} onDashboards
21
+ * @returns {DashboardInfo[]}
22
+ */
23
+ getItems(info: Object, onDashboards?: ((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)[]): DashboardInfo[];
24
+ /**
25
+ * @param {((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)} callback
26
+ * @returns {DashboardsInfo}
27
+ **/
28
+ forEachDashboard(callback: ((dashboardInfo: DashboardInfo, info: Object) => DashboardInfo)): DashboardsInfo;
29
+ /**
30
+ * @param {FolderInfo[]} path
31
+ * @returns {DashboardsInfo}
32
+ */
33
+ setPath(path: FolderInfo[]): DashboardsInfo;
34
+ }
@@ -0,0 +1,69 @@
1
+ export declare class FolderInfo {
2
+ /** @type {string|undefined} */
3
+ _vid: string | undefined;
4
+ /** @type {string|undefined} */
5
+ _sid: string | undefined;
6
+ /** @type {string|undefined} */
7
+ _name: string | undefined;
8
+ /** @type {string|undefined} */
9
+ _emoji: string | undefined;
10
+ /** @type {string|undefined} */
11
+ _parentVid: string | undefined;
12
+ /** @type {boolean} */
13
+ _fromServer: boolean;
14
+ constructor();
15
+ /**
16
+ * @returns {string|undefined}
17
+ */
18
+ get vid(): string | undefined;
19
+ /**
20
+ * @param {string} vid
21
+ * @returns {FolderInfo}
22
+ */
23
+ setVid(vid: string): FolderInfo;
24
+ /**
25
+ * @returns {string|undefined}
26
+ */
27
+ get sid(): string | undefined;
28
+ /**
29
+ * @param {string} sid
30
+ * @returns {FolderInfo}
31
+ */
32
+ setSid(sid: string): FolderInfo;
33
+ /**
34
+ * @returns {string|undefined}
35
+ */
36
+ get name(): string | undefined;
37
+ /**
38
+ * @param {string} name
39
+ * @returns {FolderInfo}
40
+ */
41
+ setName(name: string): FolderInfo;
42
+ /**
43
+ * @returns {string|undefined}
44
+ */
45
+ get emoji(): string | undefined;
46
+ /**
47
+ * @param {string} emoji
48
+ * @returns {FolderInfo}
49
+ */
50
+ setEmoji(emoji: string): FolderInfo;
51
+ /**
52
+ * @returns {string|undefined}
53
+ */
54
+ get parentVid(): string | undefined;
55
+ /**
56
+ * @param {string} parentVid
57
+ * @returns {FolderInfo}
58
+ */
59
+ setParentVid(parentVid: string): FolderInfo;
60
+ /**
61
+ * @returns {boolean}
62
+ */
63
+ get fromServer(): boolean;
64
+ /**
65
+ * @param {boolean} fromServer
66
+ * @returns {FolderInfo}
67
+ */
68
+ setFromServer(fromServer: boolean): FolderInfo;
69
+ }
@@ -0,0 +1,47 @@
1
+ export declare class GrafanaApi {
2
+ rootUrl: string | undefined;
3
+ token: string | undefined;
4
+ /**
5
+ * @param {Object} [options]
6
+ * @param {String} [options.apiUrl] - The base URL of the Grafana API
7
+ * @param {String} [options.apiToken] - The API token for authentication
8
+ */
9
+ constructor(options?: {
10
+ apiUrl?: string;
11
+ apiToken?: string;
12
+ });
13
+ /**
14
+ * @returns {{token: String, rootUrl: String}} - The parameters for the Grafana API
15
+ */
16
+ get _parameters(): {
17
+ token: string;
18
+ rootUrl: string;
19
+ };
20
+ /**
21
+ * @param {String} folderVid
22
+ * @returns {Promise<Object>} - The response from the Grafana API for the folder information as a json object
23
+ */
24
+ getFolder(folderVid: string): Promise<Object>;
25
+ /**
26
+ * @param {String} folderName
27
+ * @param {String} folderVid
28
+ * @param {String|undefined} parentVid
29
+ * @returns {Promise<Object>} The response from the Grafana API
30
+ */
31
+ createFolder(folderName: string, folderVid: string, parentVid: string | undefined): Promise<Object>;
32
+ /**
33
+ *
34
+ * @param {String} folderVid
35
+ * @param {String} newFolderName
36
+ * @param {String|undefined} parentVid
37
+ * @param {Number} version
38
+ */
39
+ renameFolder(folderVid: string, newFolderName: string, parentVid: string | undefined, version: number): Promise<Object>;
40
+ /**
41
+ * @param {Object} dashboardStruct
42
+ * @param {String} folderVid
43
+ * @param {String} message
44
+ * @returns {Promise<Object>} The response from the Grafana API
45
+ */
46
+ createDashboard(dashboardStruct: Object, folderVid: string, message: string): Promise<Object>;
47
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @param {String} url
3
+ * @param {Object} [options]
4
+ * @returns {Promise<Object>}
5
+ */
6
+ declare const getJson: (url: string, options?: Object) => Promise<Object>;
7
+ /**
8
+ * @param {String} url
9
+ * @param {Object|null|undefined} [data]
10
+ * @param {Object} [options]
11
+ * @returns {Promise<Object>}
12
+ */
13
+ declare const postJson: (url: string, data?: Object | null | undefined, options?: Object) => Promise<Object>;
14
+ /**
15
+ * @param {String} url
16
+ * @param {Object|null|undefined} [data]
17
+ * @param {Object} [options]
18
+ * @returns {Promise<Object>}
19
+ */
20
+ declare const putJson: (url: string, data?: Object | null | undefined, options?: Object) => Promise<Object>;
21
+ export { getJson, postJson, putJson };
@@ -0,0 +1,13 @@
1
+ import { DashboardsInfo } from "./index.js";
2
+ export type Info = import("@gdacm/base-types").Info;
3
+ /**
4
+ * @typedef {import("@gdacm/base-types").Info} Info
5
+ */
6
+ /**
7
+ * @param {string[]} localFolders
8
+ * @param {string} outDir
9
+ * @param {Info|Info[]} infosCode
10
+ * @param {DashboardsInfo} dashboardsInfos
11
+ * @returns {Promise<void>}
12
+ */
13
+ export declare const createDashboards: (localFolders: string[], outDir: string, infosCode: Info | Info[], dashboardsInfos: DashboardsInfo) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ export { getEnvVarsInfo, getFromOptionsOrInfo, mergeOptions, getInfo } from './info.js';
2
+ export { DashboardManager } from './DashboardManager.js';
3
+ export { DashboardProject } from './DashboardProject.js';
4
+ export { DashboardInfo } from './DashboardInfo.js';
5
+ export { DashboardsInfo } from './DashboardsInfo.js';
6
+ export { FolderInfo } from './FolderInfo.js';
7
+ export { readJsonFile, writeJsonFile, ensurePathExists, readYamlFile, writeYamlFile } from './utils/io.js';
8
+ export { createDashboards } from './dashboards.js';