cob-cli 2.52.0-beta-1 → 2.52.0

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.
@@ -1,45 +0,0 @@
1
- const Listr = require('listr');
2
- const UpdaterRenderer = require('listr-update-renderer');
3
- const verboseRenderer = require('listr-verbose-renderer');
4
- const { copyFiles } = require("./common_syncFiles");
5
- const fs = require("fs");
6
- const tar = require('tar');
7
- const { format } = require('date-fns');
8
-
9
-
10
- function executeTasks(cmdEnv, args) {
11
- console.log("\nPackaging ...");
12
-
13
- return new Listr([
14
- {title: "Apply new enviroment specifics", task: () => cmdEnv.applyCurrentCommandEnvironmentChanges() },
15
- {title: "Create staging dir", task: () => fs.existsSync('.staging') || fs.mkdirSync('.staging') },
16
- {title: "Copy files to staging dir", task: () => copyFiles(cmdEnv, "localCopy", "staging")},
17
- {title: "Create package", task: async () => { const filename = await createPackage(cmdEnv, args); console.log("created " + filename) }},
18
- {title: "Sign package", task: () => console.log("lololo")},
19
- {title: "Delete staging dir", task: () => fs.rmSync('.staging', {recursive: true, force: true})},
20
- {title: "Undo new enviroment specifics", task: () => cmdEnv.unApplyCurrentCommandEnvironmentChanges() },
21
- ], {
22
- renderer: args.verbose ? verboseRenderer : UpdaterRenderer,
23
- collapse: false
24
- });
25
- }
26
- exports.executeTasks = executeTasks;
27
-
28
- const createPackage = async function(cmdEnv, args){
29
- const filename = `${cmdEnv.servername}-${cmdEnv.name}-${format(new Date(), 'yyyy-MM-dd_HH_mm')}.tar.gz`;
30
- const files = fs.readdirSync('.staging')
31
- if (args.verbose > 0){
32
- console.log("packaging " + files)
33
- }
34
-
35
- await tar.create({
36
- gzip: true,
37
- file: filename,
38
- cwd: '.staging',
39
- onWriteEntry(entry) {
40
- if (args.verbose > 2) console.log('adding', entry.path, entry.stat.mode.toString(8))
41
- }
42
- }, files)
43
-
44
- return filename;
45
- }
@@ -1,30 +0,0 @@
1
- function getSshArgs(server) {
2
- const args = [
3
- "-o", "StrictHostKeyChecking=no",
4
- "-o", "PreferredAuthentications=publickey",
5
- "-o", "BatchMode=yes",
6
- ];
7
-
8
- if (process.env.COB_SSH_PORT) args.push("-p", process.env.COB_SSH_PORT);
9
- if (process.env.COB_SSH_IDENTITY) args.push("-i", process.env.COB_SSH_IDENTITY);
10
-
11
- const target = process.env.COB_SSH_USER ? `${process.env.COB_SSH_USER}@${server}` : server;
12
- args.push(target);
13
-
14
- return args;
15
- }
16
-
17
- function getServerAddress(server) {
18
- return process.env.COB_SSH_USER ? `${process.env.COB_SSH_USER}@${server}` : server;
19
- }
20
-
21
- function getRsyncSsh() {
22
- let cmd = "ssh -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=30 -o StrictHostKeyChecking=no";
23
-
24
- if (process.env.COB_SSH_IDENTITY) cmd += ` -i '${process.env.COB_SSH_IDENTITY}'`;
25
- if (process.env.COB_SSH_PORT) cmd += ` -p ${process.env.COB_SSH_PORT}`;
26
-
27
- return cmd;
28
- }
29
-
30
- module.exports = { getSshArgs, getServerAddress, getRsyncSsh };
@@ -1,121 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const { getFilteredDefinitions } = require('./common_definitions.js')
6
- const axios = require("axios");
7
- const inquirer = require("inquirer")
8
-
9
- async function getUntaggedChanges(servername, defId) {
10
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/${defId}/changes?tagged=false`
11
-
12
- const response = await axios.get(uri, {params: {tagged: false}});
13
-
14
- if(response.status % 200 > 100){
15
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
16
- }
17
-
18
- return ( response.data || []).filter(c => !c.tag)
19
- }
20
-
21
- async function tagDefinition(servername, defId, until) {
22
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/${defId}/tag`
23
-
24
- const params = {}
25
- if(until) {
26
- params.until = until
27
- }
28
-
29
- const response = await axios.put(uri, "", {headers: {'Content-Type': 'application/json'}, params: params});
30
-
31
- if(response.status != 200){
32
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
33
- }
34
-
35
- return response.data
36
- }
37
-
38
- async function tagDefinitions(servername, customization, defs, args) {
39
- return new Listr([
40
- {
41
- title: `(${customization}) Definitions: `.bold + "searching for definitions matching queries",
42
- task: async ctx => ctx.defs = (await getFilteredDefinitions(servername, defs))
43
- .map(d => ({id: d.id, name: d.name}))
44
- },
45
- {
46
- title: `(${customization}) Definitions: `.bold + "enriching metadata",
47
- task: async ctx => {
48
- for (const def of ctx.defs){
49
- def.changes = await getUntaggedChanges(servername, def.id)
50
- if(args.verbose) console.log(`definition ${def.name}: ${def.changes.length} untagged changes`)
51
- }
52
- }
53
- },
54
- {
55
- title: `(${customization}) Definitions: `.bold + "tagging un-tagged changes",
56
- task: async ctx => {
57
- const subtasks = ctx.defs.map(d => ({
58
- title: "Tagging changes to " + d.name.bold,
59
- task: async (_, task) => {
60
- if (d.changes.length == 0) {
61
- task.skip("no untagged changes")
62
- return
63
- }
64
-
65
- if(args.all) {
66
- await tagDefinition(servername, d.id)
67
- task.output = 'Tagged by all'
68
- return
69
- }
70
-
71
- d.changes.forEach(c => console.log(JSON.stringify(c)))
72
-
73
- const answer = await inquirer.prompt([
74
- {
75
- type: 'rawlist',
76
- name: 'action',
77
- message: `Do you wish to tag the ${d.changes.length} changes? (^c to abort)`,
78
- choices: [
79
- 'Tag Changes',
80
- 'Choose Changes',
81
- 'Skip',
82
- ]
83
- }
84
- ])
85
- if (answer.action == 'Skip') {
86
- task.skip()
87
-
88
- } else if (answer.action == 'Tag Changes') {
89
- await tagDefinition(servername, d.id)
90
- task.output = 'Tagged'
91
-
92
- } else if (answer.action == 'Choose Changes') {
93
- const dates = d.changes.reduce((acc, cur) => {
94
- if(!acc.includes(cur.date)) acc.push(cur.date)
95
- return acc
96
- }, [])
97
- const answerDate = await inquirer.prompt([
98
- {
99
- type: 'rawlist',
100
- name: 'date',
101
- message: `Choose the oldest date to tag`,
102
- choices: dates
103
- }
104
- ])
105
- await tagDefinition(servername, d.id, answerDate.date)
106
- task.output = 'Tagged until ' + answerDate.date
107
- }
108
- }
109
- }))
110
- return new Listr(subtasks)
111
- }
112
- },
113
- ],{
114
- // we need to list changes and read user input, the VerboseRenderer is needed
115
- renderer: VerboseRenderer,
116
- collapse: false
117
- }).run()
118
- }
119
-
120
-
121
- exports.tagDefinitions = tagDefinitions
@@ -1,135 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const { getFilteredDefinitions } = require('./common_definitions.js')
6
- const axios = require("axios");
7
- const fs = require("fs/promises");
8
-
9
- async function getRefs(servername, def) {
10
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/${def.id}`
11
- const response = await axios.get(uri);
12
-
13
- if(response.status != 200){
14
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
15
- }
16
-
17
- const fields = response.data.fieldDefinitions;
18
- return [...new Set(get$Refs(fields))];
19
- }
20
- function get$Refs(fields){
21
- let refs = [];
22
- for(f of fields){
23
- if(f.configuration.keys.Reference){
24
- refs.push(f.configuration.keys.Reference.args.definition);
25
- }
26
- if(f.fields) {
27
- const childRefs = get$Refs(f.fields);
28
- if(childRefs.length > 0) refs.push(...childRefs)
29
- }
30
- }
31
- return refs
32
- }
33
-
34
- async function exportDefinitionChanges(servername, def, dataPath) {
35
-
36
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/${def.id}/changes`
37
- const response = await axios.get(uri);
38
-
39
- if(response.status == 204){
40
- // this is probably an error
41
- throw new Error(`Definition "${def.name}" [${def.id}] has no tagged Changes.`);
42
-
43
- } else if(response.status != 200){
44
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
45
- }
46
-
47
- // write every change on a single line
48
- const stringified = "[\n" + response.data.map(change => " " + JSON.stringify(change)).join(',\n') + "\n]\n";
49
-
50
- await fs.writeFile(dataPath, stringified, 'utf-8');
51
- }
52
-
53
- async function exportDefinitionIdx(defs, dataPath) {
54
- await fs.writeFile(dataPath, defs.map(d => d.name).join('\n'), 'utf-8')
55
- }
56
-
57
- async function getViewsForDef(servername, definition, dataPath) {
58
- const definitionId = definition.id
59
- const uri = `https://${servername}.cultofbits.com/recordm/user/settings/${definition.views}/definitions-${definitionId}/views?`
60
-
61
- const response = await axios.get(uri);
62
-
63
- if(response.status != 200){
64
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
65
- }
66
-
67
- let userViews = response.data.filter(v => v.isShared)
68
-
69
- if(response.data.length == 0)
70
- return
71
-
72
- userViews = response.data.map(v => {
73
- v.value = JSON.stringify( JSON.parse(v.value).filter(f => f.visible == true) )
74
- return v
75
- })
76
-
77
- const jsonLines = userViews.map(v => JSON.stringify({
78
- key: v.key,
79
- value: v.value,
80
- user: v.user,
81
- })) .join('\n');
82
-
83
- await fs.writeFile(dataPath, jsonLines)
84
- }
85
-
86
- function getDefinitionsFromServer(servername, defs, definitionsPath, viewsPath, customization, args) {
87
-
88
- return new Listr(
89
- [
90
- {
91
- title: `(${customization}) Definitions: `.bold + "searching for definitions matching queries",
92
- task: async ctx => ctx.defs = await getFilteredDefinitions(servername, defs)
93
- },
94
- {
95
- title: `(${customization}) Definitions: `.bold + "enriching metadata",
96
- task: async ctx => {
97
- const definitions = await Promise.all(ctx.defs
98
- .map(async d => ({id: d.id, name: d.name, views: d.views, refs: await getRefs(servername, d)}))
99
- )
100
-
101
- // we'll sort by refs, Defs that reference others must come after them
102
- definitions.sort((a, b) => {
103
- if (a.refs.includes(b.name)){
104
- return 1;
105
- }
106
-
107
- if(b.refs.includes(a.name)){
108
- return -1;
109
- }
110
-
111
- return a.refs.length - b.refs.length;
112
- })
113
-
114
- ctx.defs = definitions
115
- }
116
- },
117
- {
118
- title: `(${customization}) Definitions: `.bold + "exporting changes",
119
- task: async ctx => {
120
- for( d of ctx.defs ){ await exportDefinitionChanges(servername, d, definitionsPath + `${d.name}.json`)}
121
- await exportDefinitionIdx(ctx.defs, definitionsPath + "_index")
122
- }
123
- },
124
- {
125
- title: `(${customization}) Definitions: `.bold + "exporting views",
126
- task: async ctx => { for (d of ctx.defs.filter(d => d.views )){ await getViewsForDef(servername, d, viewsPath + `${d.name}.jsonl`)} }
127
- },
128
- ],{
129
- renderer: args.verbose ? VerboseRenderer : UpdaterRenderer,
130
- collapse: false
131
- })
132
- }
133
-
134
-
135
- exports.getDefinitionsFromServer = getDefinitionsFromServer
@@ -1,50 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const axios = require("axios");
6
- const fs = require("fs/promises");
7
-
8
- async function domainsFromServer(servername, domainsFilter, exportPath, customization, args) {
9
- await new Listr(
10
- [
11
- { title: `(${customization}) Domains: `.bold + "searching for domains matching the queries" ,
12
- task: async ctx => ctx.domains = await getDomains(servername, domainsFilter, exportPath) },
13
- { title: `(${customization}) Domains: `.bold + "exporting domains " ,
14
- task: ctx => ctx.domains.forEach( d => exportDomain(d, exportPath)) }
15
- ],{
16
- renderer: args.verbose ? VerboseRenderer : UpdaterRenderer,
17
- collapse: false
18
- })
19
- .run()
20
- }
21
-
22
- function match(query, domain) {
23
- // simple matching for now
24
- return (domain.name && domain.name.includes(query)) ||
25
- (domain.description && domain.description.includes(query) )
26
- }
27
-
28
- async function getDomains(servername, filters, exportPath) {
29
-
30
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/domains`
31
- const response = await axios.get( uri );
32
-
33
- if(response.status != 200){
34
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
35
- }
36
-
37
- const matchesAny = (domain) => filters.filter(q => match(q, domain)).length > 0;
38
-
39
- return response.data.filter( matchesAny )
40
- }
41
-
42
- async function exportDomain(domain, rootPath) {
43
- const d = {
44
- name: domain.name,
45
- definitions: domain.definitions.map(d => d.name).sort()
46
- }
47
- await fs.writeFile(rootPath + domain.name + ".json", JSON.stringify(d, null, 2) )
48
- }
49
-
50
- exports.getDomainsFromServer = domainsFromServer
@@ -1,111 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const axios = require("axios");
6
- const fs = require("fs/promises");
7
-
8
- async function getGroups(query, servername) {
9
-
10
- const uri = `https://${servername}.cultofbits.com/userm/userm/search/userm/group?`
11
- const response = await axios.get( uri + new URLSearchParams({
12
- q: query,
13
- size: "100" // probably excessive
14
- }));
15
-
16
- if(response.status != 200){
17
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
18
- }
19
- const groupIds = response.data.hits.hits.map((h) => h._id)
20
- return groupIds;
21
- };
22
-
23
- const sortByName = (a, b) => a.name?.localeCompare(b.name);
24
-
25
- const exportGroups = async function(ids, servername, exportPath){
26
-
27
- const uri = `https://${servername}.cultofbits.com/userm/userm/group/export/${ids.join(',')}`
28
-
29
- const response = await axios.get( uri );
30
- if(response.status != 200 ){
31
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
32
- }
33
- const data = response.data;
34
-
35
- // sort everything to be easier to diff
36
- data.groups?.sort(sortByName);
37
- data.groups?.forEach(group => group.roles?.sort())
38
- data.roles?.sort(sortByName);
39
- data.roles?.forEach(role => role.perms?.sort())
40
- data.perms?.sort(sortByName)
41
- const re = /:(\d+)/g
42
- defnameCache.servername = servername;
43
-
44
- for(r of data.roles) {
45
- for(let i = 0; i < r.perms.length; i++){
46
- r.perms[i] = await replaceAsync(r.perms[i], re, replaceIdsWithName)
47
- }
48
- }
49
- for(p of data.perms){
50
- if( p.product == 'recordm') {
51
- p.name = await replaceAsync(p.name, re, replaceIdsWithName)
52
- }
53
- }
54
-
55
- fs.writeFile(exportPath, JSON.stringify(data, null, 2))
56
-
57
- };
58
-
59
- async function replaceIdsWithName(_m, g1){
60
- return ":" + ( "§§" + await defnameCache.get(g1) + "§§")
61
- }
62
-
63
- async function getGroupsFromServer(servername, groupsQueries, exportPath, customization, args) {
64
- const searchTasks = groupsQueries.map( gp =>
65
- ({ title: `(${customization}) Permissions: `.bold + "searching for groups with query: " + gp,
66
- task: async ctx => ctx.groupIds = ctx.groupIds
67
- ? ctx.groupIds.concat(await getGroups(gp, servername))
68
- : await getGroups(gp, servername) }))
69
-
70
- await new Listr(
71
- [
72
- ...searchTasks,
73
- {
74
- title: `(${customization}) Permissions: `.bold + "exporting groups and subsequent roles/permissions",
75
- task: ctx => exportGroups(ctx.groupIds, servername, exportPath)
76
- },
77
- ],{
78
- renderer: args.verbose ? VerboseRenderer : UpdaterRenderer,
79
- collapse: false
80
- })
81
- .run()
82
- }
83
-
84
- const defnameCache = {
85
- servername: '',
86
- resolved: new Map(),
87
- get: async function(id) {
88
- if(!this.resolved.has(id)){
89
- const uri = `https://${this.servername}.cultofbits.com/recordm/recordm/definitions/${id}`
90
- const response = await axios.get( uri );
91
-
92
- if(response.status != 200){
93
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
94
- }
95
-
96
- this.resolved.set(id, response.data.name)
97
- }
98
-
99
- return this.resolved.get(id)
100
- }
101
- }
102
-
103
- async function replaceAsync(string, regexp, replacerFunction) {
104
- const replacements = await Promise.all(
105
- Array.from(string.matchAll(regexp),
106
- match => replacerFunction(...match)));
107
- let i = 0;
108
- return string.replace(regexp, () => replacements[i++]);
109
- }
110
-
111
- exports.getGroupsFromServer = getGroupsFromServer
@@ -1,76 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const axios = require("axios");
6
- const fs = require("fs/promises");
7
-
8
-
9
- async function getInstancesFromServer(servername, definitionsForInstances, rootPath, customization, args) {
10
-
11
- const taskList = definitionsForInstances.map( def => ({
12
- title: `(${customization}) Instances: `.bold + `Exporting instances from definition ${def.definition}`,
13
- task: async () => getInstancesOfDefinition(servername, await getDefinition(servername, def.definition), def.query, def.crop, rootPath)
14
- }))
15
-
16
- taskList.push({
17
- title: `(${customization}) Instances: `.bold + 'Exporting _index',
18
- task: async () => await exportIndex(definitionsForInstances, rootPath + "/_index")
19
- })
20
-
21
- await new Listr(taskList , {
22
- renderer: args.verbose ? VerboseRenderer : UpdaterRenderer,
23
- collapse: false
24
- }).run()
25
- }
26
-
27
- function flattenFields(fieldArray) {
28
- if (!fieldArray || fieldArray.length == 0)
29
- return []
30
-
31
- return fieldArray.flatMap(field => flattenFields(field.fields).concat([field]))
32
- }
33
- function getFieldList(fields) {
34
- return Array.from(new Set(fields.map(f => f.name))).join(',')
35
- }
36
-
37
-
38
- async function getInstancesOfDefinition(servername, definition, query, crop, rootPath) {
39
-
40
- const definitionId = definition.id
41
- const fields = flattenFields(definition.fieldDefinitions)
42
-
43
- if(!fields.some(f => (f.description || '').includes('$instanceLabel'))){
44
- throw new Error("Should not export instances of a Definition without an $instanceLabel field, it would generate duplicates on import")
45
- }
46
- if(crop && !fields.some(f => (f.description || '').includes('$importer.last'))){
47
- throw new Error("Can not crop instances of a Definition without an $importer.last field")
48
- }
49
-
50
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/search/download/${definitionId}?`
51
- const response = await axios.get(uri + new URLSearchParams({
52
- q: query,
53
- vcn: "id," + getFieldList(fields)
54
- }), {
55
- responseType: 'arraybuffer',
56
- headers: {'export-files': 'true'}
57
- });
58
-
59
- fs.writeFile(rootPath + `${definition.name}.xlsx`, response.data)
60
-
61
- }
62
-
63
- async function getDefinition(servername, definitionName) {
64
-
65
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/name/${encodeURIComponent(definitionName)}`
66
- const response = await axios.get(uri);
67
-
68
- return response.data
69
- }
70
-
71
- async function exportIndex(defs, dataPath) {
72
- await fs.writeFile(dataPath, defs.map(d => d.definition + ":" + d.crop).join('\n'), 'utf-8')
73
- }
74
-
75
-
76
- exports.getInstancesFromServer = getInstancesFromServer
@@ -1,88 +0,0 @@
1
- require('colors');
2
- const Listr = require('listr');
3
- const UpdaterRenderer = require('listr-update-renderer');
4
- const VerboseRenderer = require('listr-verbose-renderer');
5
- const axios = require("axios");
6
- const fs = require("fs/promises");
7
-
8
- const KIBANA_TYPES = ['config','url','index-pattern','query','tag','canvas-element','canvas-workpad','action','alert','visualization','dashboard','map','lens','cases','search'];
9
-
10
- async function exportSavedObjectsOfSpace(servername, space, filePath, args) {
11
- const uri = `https://${servername}.cultofbits.com/kibana/s/${space.identifier}/api/saved_objects/_export`
12
- try {
13
- const response = await axios.post(uri, {
14
- type: KIBANA_TYPES,
15
- excludeExportDetails: true,
16
- }, {
17
- headers: { 'kbn-xsrf': 'true' },
18
- responseType: 'text',
19
- });
20
-
21
- const allObjects = response.data
22
- .split('\n')
23
- .filter(line => line.trim())
24
- .map(line => JSON.parse(line));
25
-
26
- await Promise.all(allObjects
27
- .filter(e => e.type === 'index-pattern')
28
- .map(async element => await replaceIndexPatternsIds(servername, element))
29
- )
30
-
31
- await fs.writeFile(filePath, allObjects.map(o => JSON.stringify(o)).join('\n'))
32
- } catch(err) {
33
- if(args.verbose > 0) {
34
- console.error("error downloading from kibana {status:", err.response?.status, ", uri:", uri)
35
- }
36
- throw err;
37
- }
38
- }
39
-
40
- async function exportIndex(spaces, dataPath) {
41
- await fs.writeFile(dataPath, spaces.map(s => s.identifier + ":" + s.name).join('\n'), 'utf-8')
42
- }
43
-
44
-
45
- // replaces in place
46
- async function replaceIndexPatternsIds(servername, indexPattern) {
47
- if(indexPattern.type !== "index-pattern"){
48
- throw new Error("Not an index pattern")
49
- }
50
-
51
- const definitionId = indexPattern.attributes.title.substring('recordm-'.length)
52
- const name = await getDefinitionName(servername, definitionId)
53
-
54
- indexPattern.attributes.title = `recordm-§§${name}§§`
55
- }
56
-
57
- async function getDefinitionName(servername, id) {
58
- const uri = `https://${servername}.cultofbits.com/recordm/recordm/definitions/${id}`
59
- const response = await axios.get( uri );
60
-
61
- if(response.status != 200){
62
- throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`);
63
- }
64
-
65
- return response.data.name
66
- }
67
-
68
- async function getKibanaFromServer(servername, spaces, roothpath, customization, args) {
69
-
70
- const taskList = spaces.map( space => (
71
- {
72
- title: `(${customization}) Kibana: `.bold + `Exporting ${space.name}`,
73
- task: async () => await exportSavedObjectsOfSpace(servername, space, roothpath + `/${space.name}.ndjson`, args)
74
- }
75
- ))
76
-
77
- taskList.push({
78
- title: `(${customization}) Kibana: `.bold + 'Exporting _index',
79
- task: async () => await exportIndex(spaces, roothpath + "/_index")
80
- })
81
-
82
- await new Listr( taskList, {
83
- renderer: args.verbose ? VerboseRenderer : UpdaterRenderer,
84
- collapse: false
85
- }).run()
86
- }
87
-
88
- exports.getKibanaFromServer = getKibanaFromServer