@hotglue/cli 1.0.31 → 1.0.33

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 +1 -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,326 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resetAvailableEntities = exports.patchLinkedSourceConfig = exports.patchLinkedConnectorConfig = exports.getTenants = exports.getSupportedSources = exports.getSupportedFlows = exports.getSupportedFlow = exports.getSupportedConnectors = exports.getLinkedSources = exports.getLinkedConnectors = exports.genCredentialsOnClientApi = exports.deleteTenantSchedules = void 0;
7
-
8
- var _axios = _interopRequireDefault(require("axios/dist/node/axios.cjs"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const resetAvailableEntities = async ({
13
- debug,
14
- baseUri,
15
- env,
16
- apiKey
17
- }) => {
18
- const urlObj = new URL(`${baseUri}/${env}/resetAvailableEntities`);
19
- const {
20
- data
21
- } = await _axios.default.delete(urlObj, {
22
- headers: {
23
- 'x-api-key': apiKey,
24
- 'Content-type': 'application/json'
25
- }
26
- });
27
- debug({
28
- data
29
- });
30
- };
31
-
32
- exports.resetAvailableEntities = resetAvailableEntities;
33
-
34
- const genCredentialsOnClientApi = async ({
35
- debug,
36
- baseUri,
37
- task,
38
- env,
39
- apikey,
40
- ...params
41
- }) => {
42
- const urlObj = new URL(`${baseUri}/credentials/${task}/${env}`);
43
-
44
- if (params) {
45
- Object.entries(params).forEach(([key, value]) => {
46
- urlObj.searchParams.set(key, value);
47
- });
48
- }
49
-
50
- const uri = urlObj.toString();
51
- debug && debug('uri:', uri);
52
- const {
53
- data
54
- } = await _axios.default.get(uri, {
55
- headers: {
56
- 'x-api-key': apikey
57
- }
58
- });
59
- const {
60
- accessKeyId,
61
- secretAccessKey,
62
- sessionToken
63
- } = data;
64
- return {
65
- accessKeyId,
66
- secretAccessKey,
67
- sessionToken
68
- };
69
- };
70
-
71
- exports.genCredentialsOnClientApi = genCredentialsOnClientApi;
72
-
73
- const getTenants = async ({
74
- debug,
75
- baseUri,
76
- env,
77
- apikey
78
- }) => {
79
- const uri = `${baseUri}/tenants/${env}`;
80
- debug('requesting:', uri);
81
- const {
82
- data
83
- } = await _axios.default.get(uri, {
84
- headers: {
85
- 'x-api-key': apikey
86
- }
87
- });
88
- debug('response-data', data);
89
- return data;
90
- };
91
-
92
- exports.getTenants = getTenants;
93
-
94
- const getSupportedSources = async ({
95
- debug,
96
- baseUri,
97
- env,
98
- flow,
99
- apikey
100
- }) => {
101
- const urlObj = new URL(`${baseUri}/${env}/${flow}/supportedSources`);
102
- const headers = {
103
- 'x-api-key': apikey
104
- };
105
- const uri = urlObj.toString();
106
- debug && debug('uri:', uri);
107
- const {
108
- data
109
- } = await _axios.default.get(uri, {
110
- headers
111
- });
112
- return data;
113
- };
114
-
115
- exports.getSupportedSources = getSupportedSources;
116
-
117
- const getSupportedConnectors = async ({
118
- debug,
119
- baseUri,
120
- env,
121
- flow,
122
- apikey
123
- }) => {
124
- const urlObj = new URL(`${baseUri}/v2/${env}/${flow}/supportedConnectors`);
125
- const headers = {
126
- 'x-api-key': apikey
127
- };
128
- const uri = urlObj.toString();
129
- debug && debug('uri:', uri);
130
- const {
131
- data
132
- } = await _axios.default.get(uri, {
133
- headers
134
- });
135
- return data;
136
- };
137
-
138
- exports.getSupportedConnectors = getSupportedConnectors;
139
-
140
- const getLinkedSources = async ({
141
- debug,
142
- baseUri,
143
- env,
144
- flow,
145
- tenant,
146
- apikey,
147
- config
148
- }) => {
149
- const urlObj = new URL(`${baseUri}/${env}/${flow}/${tenant}/linkedSources`);
150
-
151
- if (config) {
152
- urlObj.searchParams.set('config', 'true');
153
- }
154
-
155
- const headers = {
156
- 'x-api-key': apikey
157
- };
158
- const uri = urlObj.toString();
159
- debug && debug('uri:', uri);
160
- const {
161
- data
162
- } = await _axios.default.get(uri, {
163
- headers
164
- });
165
- return data;
166
- };
167
-
168
- exports.getLinkedSources = getLinkedSources;
169
-
170
- const getLinkedConnectors = async ({
171
- debug,
172
- baseUri,
173
- env,
174
- flow,
175
- tenant,
176
- apikey,
177
- config
178
- }) => {
179
- const urlObj = new URL(`${baseUri}/v2/${env}/${flow}/${tenant}/linkedConnectors`);
180
-
181
- if (config) {
182
- urlObj.searchParams.set('config', 'true');
183
- }
184
-
185
- const headers = {
186
- 'x-api-key': apikey
187
- };
188
- const uri = urlObj.toString();
189
- debug && debug('uri:', uri);
190
- const {
191
- data
192
- } = await _axios.default.get(uri, {
193
- headers
194
- });
195
- return data;
196
- };
197
-
198
- exports.getLinkedConnectors = getLinkedConnectors;
199
-
200
- const patchLinkedSourceConfig = async ({
201
- debug,
202
- baseUri,
203
- env,
204
- flow,
205
- tenant,
206
- apikey,
207
- connectorId,
208
- config
209
- }) => {
210
- const urlObj = new URL(`${baseUri}/${env}/${flow}/${tenant}/linkedSources`);
211
- const headers = {
212
- 'x-api-key': apikey
213
- };
214
- const uri = urlObj.toString();
215
- const body = {
216
- tap: connectorId,
217
- config
218
- };
219
- debug && debug('uri:', uri);
220
- const {
221
- data
222
- } = await _axios.default.patch(uri, body, {
223
- headers
224
- });
225
- return data;
226
- };
227
-
228
- exports.patchLinkedSourceConfig = patchLinkedSourceConfig;
229
-
230
- const patchLinkedConnectorConfig = async ({
231
- debug,
232
- baseUri,
233
- env,
234
- flow,
235
- tenant,
236
- apikey,
237
- connectorId,
238
- config
239
- }) => {
240
- const urlObj = new URL(`${baseUri}/v2/${env}/${flow}/${tenant}/linkedConnectors`);
241
- const headers = {
242
- 'x-api-key': apikey
243
- };
244
- const uri = urlObj.toString();
245
- const body = {
246
- connector_id: connectorId,
247
- config
248
- };
249
- debug && debug('uri:', uri);
250
- const {
251
- data
252
- } = await _axios.default.patch(uri, body, {
253
- headers
254
- });
255
- return data;
256
- };
257
-
258
- exports.patchLinkedConnectorConfig = patchLinkedConnectorConfig;
259
-
260
- const getSupportedFlows = async ({
261
- debug,
262
- baseUri,
263
- env,
264
- apikey
265
- }) => {
266
- const urlObj = new URL(`${baseUri}/${env}/flows/supported`);
267
- const headers = {
268
- 'x-api-key': apikey
269
- };
270
- const uri = urlObj.toString();
271
- debug && debug('uri:', uri);
272
- const {
273
- data
274
- } = await _axios.default.get(uri, {
275
- headers
276
- });
277
- return data;
278
- };
279
-
280
- exports.getSupportedFlows = getSupportedFlows;
281
-
282
- const getSupportedFlow = async ({
283
- debug,
284
- baseUri,
285
- env,
286
- flow,
287
- apikey
288
- }) => {
289
- const urlObj = new URL(`${baseUri}/${env}/flows/${flow}/supported`);
290
- const headers = {
291
- 'x-api-key': apikey
292
- };
293
- const uri = urlObj.toString();
294
- debug && debug('uri:', uri);
295
- const {
296
- data
297
- } = await _axios.default.get(uri, {
298
- headers
299
- });
300
- return data;
301
- };
302
-
303
- exports.getSupportedFlow = getSupportedFlow;
304
-
305
- const deleteTenantSchedules = async ({
306
- debug,
307
- baseUri,
308
- env,
309
- apikey,
310
- tenant
311
- }) => {
312
- const urlObj = new URL(`${baseUri}/tenant/${env}/${tenant}?schedules_only=true`);
313
- const headers = {
314
- 'x-api-key': apikey
315
- };
316
- const uri = urlObj.toString();
317
- debug && debug('uri:', uri);
318
- const {
319
- data
320
- } = await _axios.default.delete(uri, {
321
- headers
322
- });
323
- return data;
324
- };
325
-
326
- exports.deleteTenantSchedules = deleteTenantSchedules;
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.baseBuilder = exports.baseApiBuilder = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("./debug"));
9
-
10
- var _descriptions = _interopRequireDefault(require("./descriptions"));
11
-
12
- var _config = require("./config");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- const debug = (0, _debug.default)('base');
17
-
18
- const baseBuilder = yargs => {
19
- return yargs;
20
- };
21
-
22
- exports.baseBuilder = baseBuilder;
23
-
24
- const baseApiBuilder = async yargs => {
25
- debug('builder');
26
- const config = await (0, _config.getCombinedConfig)();
27
- return baseBuilder(yargs).option('apikey', _descriptions.default.options['apikey'].config).option('env', _descriptions.default.options['env'].config).option('json', _descriptions.default.options['json'].config).config(config).demandOption(['env'], _descriptions.default.options['env'].demandText).demandOption(['apikey'], _descriptions.default.options['apikey'].demandText);
28
- };
29
-
30
- exports.baseApiBuilder = baseApiBuilder;
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.writeConfigFile = exports.staticOptions = exports.getProjectConfig = exports.getProfileConfigFilePath = exports.getProfileConfig = exports.getCombinedConfig = void 0;
7
-
8
- var _os = require("os");
9
-
10
- var _promises = require("fs/promises");
11
-
12
- var _path = _interopRequireDefault(require("path"));
13
-
14
- var _cosmiconfig = require("cosmiconfig");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- /*
19
- Precedence of CLI configuration (from highest to lowest):
20
- per cli execution: pass config file (--config /path/to/.hotgluerc) option with your command
21
- per project: load from current project's package.json or a config folder in any folder in the path (i.e. /path/to/project/.hotgluerc)
22
- per user: ~/.hotglue/config.yaml
23
- any built-in or default config settings
24
- */
25
- const staticOptions = {
26
- hg: {
27
- appName: 'hotglue',
28
- clientApiBaseUri: process.env.HOTGLUE_CLIENT_API_BASE_URI || 'https://client-api.hotglue.xyz',
29
- defaultConfigFileName: 'config.yaml'
30
- }
31
- };
32
- exports.staticOptions = staticOptions;
33
- const defaultOptions = {// absolute path or a relative path using dot notation only
34
- // downloadFolder: path.resolve(process.cwd(), 'downloads'),
35
- };
36
-
37
- const getProfileConfigFilePath = () => _path.default.resolve((0, _os.homedir)(), `.${staticOptions.hg.appName}`, staticOptions.hg.defaultConfigFileName);
38
-
39
- exports.getProfileConfigFilePath = getProfileConfigFilePath;
40
-
41
- const writeConfigFile = async (file, data) => {
42
- await (0, _promises.mkdir)(_path.default.dirname(file), {
43
- recursive: true
44
- });
45
- await (0, _promises.writeFile)(file, data);
46
- };
47
-
48
- exports.writeConfigFile = writeConfigFile;
49
-
50
- const getProfileConfig = async () => {
51
- const {
52
- appName
53
- } = staticOptions.hg;
54
-
55
- try {
56
- const result = await (0, _cosmiconfig.cosmiconfig)(appName).load(getProfileConfigFilePath());
57
- return result || {}; // return { ...result.config };
58
- } catch (err) {
59
- // no profile config found; app not configured
60
- return {};
61
- }
62
- };
63
-
64
- exports.getProfileConfig = getProfileConfig;
65
-
66
- const getProjectConfig = async () => {
67
- const {
68
- appName
69
- } = staticOptions.hg;
70
- const cosmic = (0, _cosmiconfig.cosmiconfig)(appName, {
71
- searchPlaces: [// primary
72
- `${appName}.yaml`, `.${appName}.yaml`, `.${appName}rc.yaml`, `.${appName}rc.yml`, // secondary
73
- `.${appName}rc`, `.${appName}rc.json`, `.${appName}rc.js` // `package.json`,
74
- ] // loaders: [],
75
- // packageProp: `${appName}`,
76
- // stopDir: '',
77
- // cache: true,
78
- // transform: (res) => res
79
-
80
- });
81
-
82
- try {
83
- const result = await cosmic.search();
84
- return result || {}; // return (result && result.config) || {};
85
- } catch (err) {
86
- console.log(err); // use debug()
87
-
88
- throw new Error(`Malformed configuration file: ${err.message}`);
89
- }
90
- };
91
-
92
- exports.getProjectConfig = getProjectConfig;
93
-
94
- const getCombinedConfig = async () => {
95
- const profileConfig = await getProfileConfig();
96
- const projectConfig = await getProjectConfig();
97
- const result = { ...defaultOptions,
98
- ...profileConfig.config,
99
- ...projectConfig.config
100
- }; // todo: post-process config (i.e. template replacement)
101
-
102
- return result;
103
- };
104
-
105
- exports.getCombinedConfig = getCombinedConfig;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _debug = _interopRequireDefault(require("debug"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const debug = (0, _debug.default)('hotglue-cli');
13
-
14
- function extendDebug(namespace) {
15
- return debug.extend(namespace);
16
- }
17
-
18
- var _default = extendDebug;
19
- exports.default = _default;
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- // get description for key: .option(...((key) => [key, descriptions[key]])('apikey'))
8
- var _default = {
9
- commands: {},
10
- options: {
11
- env: {
12
- config: {
13
- describe: 'Environment Id',
14
- type: 'string',
15
- alias: ['e']
16
- },
17
- demandText: 'The "env" parameter (Environment Id) is required. Either pass here using `-e [env_id]` or add an env property in your rc file.'
18
- },
19
- apikey: {
20
- config: {
21
- describe: 'API key',
22
- type: 'string',
23
- alias: ['k']
24
- },
25
- demandText: 'API key is required. Either pass here using -k [key] or configure your profile using config set.'
26
- },
27
- json: {
28
- config: {
29
- describe: 'Makes the output format to be JSON',
30
- type: 'boolean',
31
- default: false
32
- },
33
- demandText: ''
34
- },
35
- tenant: {
36
- config: {
37
- describe: 'Tenant (user) ID',
38
- type: 'string',
39
- alias: ['u']
40
- },
41
- demandText: 'TenantId is required. You can pass it using -u [tenantId].'
42
- },
43
- flow: {
44
- config: {
45
- describe: 'Flow ID',
46
- type: 'string',
47
- alias: ['f']
48
- },
49
- demandText: 'FlowId is required. You can pass it using -f [flow_id].'
50
- },
51
- tap: {
52
- config: {
53
- describe: 'Tap name',
54
- type: 'string',
55
- alias: ['t']
56
- },
57
- demandText: 'Tap name is required. You can pass it using -t <tap_name>.'
58
- },
59
- connector: {
60
- config: {
61
- describe: 'Connector ID',
62
- type: 'string',
63
- alias: ['c']
64
- },
65
- demandText: 'Connector ID is required. You can pass it using -c <connector>.'
66
- },
67
- all: {
68
- config: {
69
- describe: 'Run command for all taps/connectors',
70
- type: 'boolean',
71
- default: false,
72
- alias: ['a']
73
- },
74
- demandText: 'This "all" flag is required. You can pass it using -a or --all.'
75
- },
76
- jobroot: {
77
- config: {
78
- describe: 'Job Root (S3 prefix)',
79
- type: 'string',
80
- alias: ['j']
81
- },
82
- demandText: 'JobRoot key is required. You can pass it using -j [job_root].'
83
- },
84
- count: {
85
- config: {
86
- describe: 'Max returned records',
87
- type: 'number'
88
- }
89
- },
90
- downloadTo: {
91
- config: {
92
- describe: 'Download folder',
93
- default: '.',
94
- type: 'string',
95
- alias: ['d']
96
- },
97
- demandText: 'A destination folder is required. You can pass it using -d [folder] and can be either relative from cwd or absolute.'
98
- },
99
- sourceFolder: {
100
- config: {
101
- describe: 'Source folder',
102
- type: 'string',
103
- default: '.',
104
- alias: ['s']
105
- },
106
- demandText: ''
107
- },
108
- configFilePath: {
109
- config: {
110
- describe: 'Config file path',
111
- type: 'string',
112
- default: './config.json',
113
- alias: ['p']
114
- },
115
- demandText: 'Local path of the config (with .json extension). Example: "/home/hotglue/config.json"'
116
- },
117
- overwrite: {
118
- config: {
119
- describe: 'Overwrite existing',
120
- type: 'boolean',
121
- default: false,
122
- alias: ['o']
123
- },
124
- demandText: ''
125
- },
126
- cleanup: {
127
- config: {
128
- describe: 'Clean up target prior to action',
129
- type: 'boolean',
130
- default: false,
131
- alias: ['c']
132
- },
133
- demandText: ''
134
- }
135
- }
136
- };
137
- exports.default = _default;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isV2Flow = exports.getEntityLabel = void 0;
7
-
8
- var _utils = require("./utils");
9
-
10
- const isV2Flow = async (s3, envId, tenantId, flowId) => {
11
- try {
12
- const fileStream = s3.getObject({
13
- Bucket: envId,
14
- Key: `${tenantId}/flows/${flowId}/flow.json`
15
- }).createReadStream();
16
- const fileString = await (0, _utils.streamToString)(fileStream);
17
- const fileJson = JSON.parse(fileString);
18
- return fileJson.version === 2;
19
- } catch (error) {
20
- return false;
21
- }
22
- };
23
-
24
- exports.isV2Flow = isV2Flow;
25
-
26
- const getEntityLabel = async (s3, envId, tenantId, flowId, isV2 = undefined) => {
27
- const _isV2Flow = isV2 ?? (await isV2Flow(s3, envId, tenantId, flowId));
28
-
29
- return _isV2Flow ? 'connectors' : 'taps';
30
- };
31
-
32
- exports.getEntityLabel = getEntityLabel;