@hotglue/cli 1.0.32 → 1.0.34

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/index.js +9 -8
  3. package/lib/cjs/index.js.map +1 -1
  4. package/lib/mjs/index.js +9 -8
  5. package/lib/mjs/index.js.map +1 -1
  6. package/package.json +2 -1
  7. package/lib/commands/config/set.js +0 -82
  8. package/lib/commands/config.js +0 -69
  9. package/lib/commands/env/deploy.js +0 -162
  10. package/lib/commands/env/download.js +0 -169
  11. package/lib/commands/env.js +0 -32
  12. package/lib/commands/etl/delete.js +0 -171
  13. package/lib/commands/etl/deploy.js +0 -263
  14. package/lib/commands/etl/download.js +0 -205
  15. package/lib/commands/etl.js +0 -32
  16. package/lib/commands/flows/list.js +0 -104
  17. package/lib/commands/flows.js +0 -32
  18. package/lib/commands/jobs/download.js +0 -188
  19. package/lib/commands/jobs/list.js +0 -108
  20. package/lib/commands/jobs.js +0 -32
  21. package/lib/commands/snapshots/deploy.js +0 -202
  22. package/lib/commands/snapshots/download.js +0 -213
  23. package/lib/commands/snapshots.js +0 -32
  24. package/lib/commands/tenants/custom-etl.js +0 -183
  25. package/lib/commands/tenants/custom-field-map.js +0 -191
  26. package/lib/commands/tenants/delete.js +0 -150
  27. package/lib/commands/tenants/list.js +0 -97
  28. package/lib/commands/tenants/updateConfig.js +0 -188
  29. package/lib/commands/tenants.js +0 -32
  30. package/lib/helpers/api.js +0 -326
  31. package/lib/helpers/baseBuilder.js +0 -30
  32. package/lib/helpers/config.js +0 -105
  33. package/lib/helpers/debug.js +0 -19
  34. package/lib/helpers/descriptions.js +0 -137
  35. package/lib/helpers/flow.js +0 -32
  36. package/lib/helpers/print.js +0 -92
  37. package/lib/helpers/utils.js +0 -245
  38. package/lib/index.js +0 -12
  39. package/lib/main.js +0 -27
@@ -1,150 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.handler = exports.desc = exports.command = exports.builder = void 0;
7
-
8
- var _awsSdk = _interopRequireDefault(require("aws-sdk"));
9
-
10
- var _ora = _interopRequireDefault(require("ora"));
11
-
12
- var _cliTable = _interopRequireDefault(require("cli-table"));
13
-
14
- var _debug = _interopRequireDefault(require("../../helpers/debug"));
15
-
16
- var _descriptions = _interopRequireDefault(require("../../helpers/descriptions"));
17
-
18
- var _print = require("../../helpers/print");
19
-
20
- var _api = require("../../helpers/api");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- const debug = (0, _debug.default)('commands:tenants:delete');
25
- const command = 'delete';
26
- exports.command = command;
27
- const desc = 'Delete tenant';
28
- exports.desc = desc;
29
-
30
- const builder = async yargs => {
31
- debug('builder', command);
32
- return yargs.option('tenant', _descriptions.default.options['tenant'].config);
33
- };
34
-
35
- exports.builder = builder;
36
-
37
- const handler = async argv => {
38
- debug('handler', command, argv);
39
- const {
40
- hg,
41
- json,
42
- apikey,
43
- env,
44
- tenant
45
- } = argv;
46
- const {
47
- clientApiBaseUri
48
- } = hg;
49
- let message;
50
- let spinner = (0, _ora.default)();
51
-
52
- try {
53
- if (tenant === 'default') {
54
- throw new Error('It\'s not possible to delete "default" tenant!');
55
- }
56
-
57
- message = (0, _print.themed)(`Deleting tenant ${tenant} schedules`);
58
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
59
- await (0, _api.deleteTenantSchedules)({
60
- debug,
61
- baseUri: clientApiBaseUri,
62
- env,
63
- apikey,
64
- tenant
65
- });
66
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
67
- message = (0, _print.themed)(`Verifying user and authorizing`);
68
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
69
- const {
70
- accessKeyId,
71
- secretAccessKey,
72
- sessionToken
73
- } = await (0, _api.genCredentialsOnClientApi)({
74
- debug,
75
- baseUri: clientApiBaseUri,
76
- task: 'tenant-delete',
77
- env,
78
- tenant,
79
- apikey
80
- });
81
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // created authenticated S3 instance
82
-
83
- const s3 = new _awsSdk.default.S3({
84
- accessKeyId,
85
- secretAccessKey,
86
- sessionToken
87
- });
88
- message = (0, _print.themed)(`Deleting tenant ${tenant} for environment ${(0, _print.themed)(env, 'info')}`);
89
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
90
-
91
- while (true) {
92
- // List objects, 1000 keys at a time
93
- const s3Objects = await s3.listObjectsV2({
94
- Bucket: env,
95
- Prefix: `${tenant}/`
96
- }).promise();
97
- const Objects = (s3Objects.Contents || []).map(({
98
- Key
99
- }) => ({
100
- Key
101
- }));
102
-
103
- if (Objects.length === 0) {
104
- break;
105
- } // Purge the objects
106
-
107
-
108
- const response = await s3.deleteObjects({
109
- Bucket: env,
110
- Delete: {
111
- Objects
112
- }
113
- }).promise();
114
- }
115
-
116
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
117
-
118
- if (json) {
119
- (0, _print.printJSON)({
120
- statu: 'success',
121
- tenantDeleted: tenant
122
- });
123
- } else {
124
- // generate results table
125
- const table = new _cliTable.default({
126
- head: ['Tenant ID']
127
- });
128
- table.push([tenant]); // print results
129
-
130
- console.log(table.toString());
131
- }
132
- } catch (err) {
133
- if (json) {
134
- (0, _print.printJSON)({
135
- status: 'error',
136
- error: err
137
- });
138
- } else {
139
- spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
140
- (0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
141
- debug(err);
142
-
143
- if (err && err.response && err.response.data) {
144
- debug('response', err.response.data);
145
- }
146
- }
147
- }
148
- };
149
-
150
- exports.handler = handler;
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.handler = exports.desc = exports.command = exports.builder = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("../../helpers/debug"));
9
-
10
- var _ora = _interopRequireDefault(require("ora"));
11
-
12
- var _axios = _interopRequireDefault(require("axios/dist/node/axios.cjs"));
13
-
14
- var _cliTable = _interopRequireDefault(require("cli-table"));
15
-
16
- var _descriptions = _interopRequireDefault(require("../../helpers/descriptions"));
17
-
18
- var _print = require("../../helpers/print");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- const debug = (0, _debug.default)('commands:tenants:list');
23
- const command = 'list';
24
- exports.command = command;
25
- const desc = 'List tenants';
26
- exports.desc = desc;
27
-
28
- const builder = async yargs => {
29
- debug('builder', command);
30
- return yargs.option('tenant', _descriptions.default.options['tenant'].config);
31
- };
32
-
33
- exports.builder = builder;
34
-
35
- const handler = async argv => {
36
- debug('handler', command, argv);
37
- const {
38
- hg,
39
- json,
40
- apikey,
41
- env,
42
- tenant
43
- } = argv;
44
- let message;
45
- let spinner = (0, _ora.default)();
46
-
47
- try {
48
- // 1. get data from client-api backend
49
- message = (0, _print.themed)(`Retrieving tenants for environment ${(0, _print.themed)(env, 'info')}`);
50
- const uri = `${hg.clientApiBaseUri}/tenants/${env}${tenant ? `?tenant=${tenant}` : ''}`;
51
- debug('requesting:', uri);
52
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
53
- const {
54
- data
55
- } = await _axios.default.get(uri, {
56
- headers: {
57
- 'x-api-key': apikey
58
- }
59
- });
60
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
61
- debug('response-data', data); // exit if there is no data
62
-
63
- if (!data || data.length === 0) {
64
- json ? (0, _print.printJSON)([]) : spinner.info((0, _print.themed)(`Info: ${(0, _print.themed)('No tenants found in the specified environment')}.`, 'secondary'));
65
- return;
66
- }
67
-
68
- if (json) {
69
- (0, _print.printJSON)(data);
70
- } else {
71
- // generate results table
72
- const table = new _cliTable.default({
73
- head: ['tenant ID']
74
- });
75
- table.push(...data.map(item => [item])); // print results
76
-
77
- console.log(table.toString());
78
- }
79
- } catch (err) {
80
- if (json) {
81
- (0, _print.printJSON)({
82
- status: 'error',
83
- error: err
84
- });
85
- } else {
86
- spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
87
- (0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
88
- debug(err);
89
-
90
- if (err && err.response && err.response.data) {
91
- debug('response', err.response.data);
92
- }
93
- }
94
- }
95
- };
96
-
97
- exports.handler = handler;
@@ -1,188 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.handler = exports.desc = exports.command = exports.builder = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("../../helpers/debug.js"));
9
-
10
- var _ora = _interopRequireDefault(require("ora"));
11
-
12
- var _cliTable = _interopRequireDefault(require("cli-table"));
13
-
14
- var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
15
-
16
- var _print = require("../../helpers/print.js");
17
-
18
- var _api = require("../../helpers/api.js");
19
-
20
- var _utils = require("../../helpers/utils.js");
21
-
22
- var _fs = require("fs");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- const debug = (0, _debug.default)('commands:tenants:update-config');
27
- const command = 'update-config';
28
- exports.command = command;
29
- const desc = 'Update the config of a specific connector and flow for all tenants';
30
- exports.desc = desc;
31
-
32
- const builder = async yargs => {
33
- debug('builder', command);
34
- return yargs.option('flow', _descriptions.default.options['flow'].config).demandOption('flow', _descriptions.default.options['flow'].demandText).option('connector', _descriptions.default.options['connector'].config).demandOption('connector', _descriptions.default.options['connector'].demandText).option('configFilePath', _descriptions.default.options['configFilePath'].config).demandOption('configFilePath', _descriptions.default.options['configFilePath'].demandText);
35
- };
36
-
37
- exports.builder = builder;
38
-
39
- const processTenant = async ({
40
- debug,
41
- baseUri,
42
- apikey,
43
- env,
44
- flow,
45
- tenant,
46
- connectorId,
47
- config,
48
- isV2Flow
49
- }) => {
50
- const lookupKey = isV2Flow ? 'id' : 'tap'; // Get all linked connectors/sources of the tuple (env, flow, tenant)
51
-
52
- const linkedConnectors = isV2Flow ? await (0, _api.getLinkedConnectors)({
53
- debug,
54
- baseUri,
55
- env,
56
- flow,
57
- tenant,
58
- apikey,
59
- config: true
60
- }) : await (0, _api.getLinkedSources)({
61
- debug,
62
- baseUri,
63
- env,
64
- flow,
65
- tenant,
66
- apikey,
67
- config: true
68
- });
69
- const connector = linkedConnectors.find(c => c[lookupKey] === connectorId);
70
- if (!connector) return null;
71
- const patchFunction = isV2Flow ? _api.patchLinkedConnectorConfig : _api.patchLinkedSourceConfig;
72
-
73
- try {
74
- await patchFunction({
75
- debug,
76
- baseUri,
77
- env,
78
- flow,
79
- tenant,
80
- apikey,
81
- connectorId,
82
- config
83
- });
84
- } catch (e) {
85
- console.log((0, _print.themed)(`Error patching: ${tenant}. ${e}`, 'secondary'));
86
- }
87
-
88
- return tenant;
89
- };
90
-
91
- const handler = async argv => {
92
- debug('handler', command, argv);
93
- const {
94
- hg,
95
- json,
96
- apikey,
97
- env,
98
- flow,
99
- connector,
100
- configFilePath
101
- } = argv;
102
- let message;
103
- let spinner = (0, _ora.default)();
104
-
105
- try {
106
- if (!configFilePath) {
107
- throw new Error('Config file path not provided');
108
- }
109
-
110
- if (!configFilePath.endsWith('.json')) {
111
- throw new Error('Config file must have .json extension');
112
- }
113
-
114
- if (!(0, _fs.existsSync)(configFilePath)) {
115
- throw new Error('Config file not found');
116
- }
117
-
118
- const config = JSON.parse((0, _fs.readFileSync)(configFilePath, {
119
- encoding: 'utf-8'
120
- }));
121
- message = (0, _print.themed)(`Retrieving tenants for environment ${(0, _print.themed)(env, 'info')}`);
122
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
123
- const [allTenants, supportedFlow] = await Promise.all([(0, _api.getTenants)({
124
- debug,
125
- baseUri: hg.clientApiBaseUri,
126
- apikey,
127
- env
128
- }), (0, _api.getSupportedFlow)({
129
- debug,
130
- baseUri: hg.clientApiBaseUri,
131
- apikey,
132
- env,
133
- flow
134
- })]);
135
- const isV2Flow = (supportedFlow === null || supportedFlow === void 0 ? void 0 : supportedFlow.version) === 2;
136
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
137
- const tenantsUpdated = [];
138
- message = (0, _print.themed)(`Updating config for connector ${(0, _print.themed)(connector, 'info')} and flow ${(0, _print.themed)(flow, 'info')}`);
139
- !json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary')); // Break the tenants array in to an array of arrays so we can make
140
- // parallel calls and make it faster
141
-
142
- for (const tenants of (0, _utils.buildChunks)(allTenants)) {
143
- const maybeTenantsUpdated = await Promise.all(tenants.map(tenant => processTenant({
144
- debug,
145
- baseUri: hg.clientApiBaseUri,
146
- apikey,
147
- env,
148
- flow,
149
- tenant,
150
- connectorId: connector,
151
- config,
152
- isV2Flow
153
- })));
154
- tenantsUpdated.push(...maybeTenantsUpdated.filter(Boolean));
155
- }
156
-
157
- !json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
158
-
159
- if (json) {
160
- (0, _print.printJSON)(tenantsUpdated);
161
- } else {
162
- // generate results table
163
- const table = new _cliTable.default({
164
- head: ['Tenant ID']
165
- });
166
- tenantsUpdated.forEach(t => table.push([t])); // print results
167
-
168
- console.log(table.toString());
169
- }
170
- } catch (err) {
171
- if (json) {
172
- (0, _print.printJSON)({
173
- status: 'error',
174
- error: err
175
- });
176
- } else {
177
- spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
178
- (0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
179
- debug(err);
180
-
181
- if (err && err.response && err.response.data) {
182
- debug('response', err.response.data);
183
- }
184
- }
185
- }
186
- };
187
-
188
- exports.handler = handler;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.handler = exports.desc = exports.command = exports.builder = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("../helpers/debug"));
9
-
10
- var _baseBuilder = require("../helpers/baseBuilder");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const debug = (0, _debug.default)('commands:tenants');
15
- const command = 'tenants <action>';
16
- exports.command = command;
17
- const desc = 'Manage tenants';
18
- exports.desc = desc;
19
-
20
- const builder = async function (yargs) {
21
- debug('builder', command);
22
- const base = await (0, _baseBuilder.baseApiBuilder)(yargs);
23
- return base.commandDir('tenants');
24
- };
25
-
26
- exports.builder = builder;
27
-
28
- const handler = async function (argv) {
29
- debug('handler', command, argv);
30
- };
31
-
32
- exports.handler = handler;