@parsable/plugin-author-cli 1.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.
Files changed (52) hide show
  1. package/README.md +405 -0
  2. package/bin/run +5 -0
  3. package/bin/run.cmd +3 -0
  4. package/oclif.manifest.json +1 -0
  5. package/package.json +67 -0
  6. package/src/commands/base.js +38 -0
  7. package/src/commands/exec-data/delete.js +161 -0
  8. package/src/commands/jobs/create.js +100 -0
  9. package/src/commands/jobs/delete.js +97 -0
  10. package/src/commands/template/copy/status.js +66 -0
  11. package/src/commands/template/copy.js +191 -0
  12. package/src/config/index.js +40 -0
  13. package/src/index.js +1 -0
  14. package/src/services/client/admin.js +81 -0
  15. package/src/services/client/copy-template-status-client-fn.js +18 -0
  16. package/src/services/client/create-template-client-fn.js +19 -0
  17. package/src/services/client/field-data.js +29 -0
  18. package/src/services/client/helpers/create-user-agent-header.js +13 -0
  19. package/src/services/client/helpers/create-wi-platform-header.js +3 -0
  20. package/src/services/client/index.js +11 -0
  21. package/src/services/client/mothership-client-fn.js +15 -0
  22. package/src/services/exec-data/delete-fn.js +41 -0
  23. package/src/services/exec-data/index.js +9 -0
  24. package/src/services/helpers/convert-kebab-case-to-camel-case.js +6 -0
  25. package/src/services/helpers/custom-exception.js +12 -0
  26. package/src/services/helpers/delay-resolve.js +8 -0
  27. package/src/services/helpers/serial-async-csv-reader.js +53 -0
  28. package/src/services/jobs/create-fn.js +106 -0
  29. package/src/services/jobs/delete-fn.js +175 -0
  30. package/src/services/jobs/index.js +11 -0
  31. package/src/services/render/helper/std-err-log.js +4 -0
  32. package/src/services/render/helper/translations.js +107 -0
  33. package/src/services/render/index.js +15 -0
  34. package/src/services/render/render-copy-template-success-fn.js +22 -0
  35. package/src/services/render/render-exception-fn.js +37 -0
  36. package/src/services/render/render-statuses-fn.js +51 -0
  37. package/src/services/template_copy/create-lambda-payload.js +36 -0
  38. package/src/services/template_copy/get-auth-token-fn.js +33 -0
  39. package/src/services/template_copy/get-config-from-path.js +13 -0
  40. package/src/services/template_copy/getConfigFromFlagsAndPrompts/convert-inputs-to-config-format.js +9 -0
  41. package/src/services/template_copy/getConfigFromFlagsAndPrompts/create-questions-for-prompt.js +129 -0
  42. package/src/services/template_copy/getConfigFromFlagsAndPrompts/find-missing-required-flags.js +30 -0
  43. package/src/services/template_copy/getConfigFromFlagsAndPrompts/index.js +24 -0
  44. package/src/services/template_copy/helpers/config-json.schema.js +79 -0
  45. package/src/services/template_copy/helpers/config-to-payload.map.js +37 -0
  46. package/src/services/template_copy/helpers/prompt-to-config.map.js +64 -0
  47. package/src/services/template_copy/index.js +21 -0
  48. package/src/services/template_copy/send-copy-template-request-fn.js +21 -0
  49. package/src/services/template_copy/validate-config-json-fn.js +19 -0
  50. package/src/services/template_status/get-status-fn.js +30 -0
  51. package/src/services/template_status/index.js +11 -0
  52. package/src/services/template_status/prompt.js +34 -0
@@ -0,0 +1,161 @@
1
+ const {flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+ const fs = require('fs')
4
+
5
+ const BaseCommand = require('../base.js')
6
+ const renderFn = require('../../services/render')
7
+ const execDataServiceFn = require('../../services/exec-data')
8
+
9
+ const confirmationPrompt = `You are about to permanently delete execution data. This cannot be undone. Are you sure you want to proceed?
10
+ If so, type "yes" and return. Otherwise, type anything else or CTRL-c.
11
+ To suppress this step in the future, use the flag --force`
12
+
13
+ class DeleteCommand extends BaseCommand {
14
+ async run() {
15
+ const {flags} = this.parse(DeleteCommand)
16
+ const render = renderFn({flags})
17
+
18
+ const raisePrompt = !flags.force
19
+ if (raisePrompt) {
20
+ const promptResponse = await cli.prompt(confirmationPrompt)
21
+ if (promptResponse === 'yes') {
22
+ cli.info('Confirmed. Proceeding.')
23
+ } else {
24
+ cli.error(`Confirmation response (${promptResponse}) was not "yes". Cancelling deletion.`)
25
+ return
26
+ }
27
+ }
28
+
29
+ let deletePayload = {}
30
+
31
+ if (!flags.all && !flags['from-time'] && !flags['until-time']) {
32
+ cli.error('Must specify either "--all", or one/both of "--from-time" and/or "--until-time"')
33
+ }
34
+ if (flags['from-time']) {
35
+ deletePayload.fromTime = flags['from-time']
36
+ }
37
+ if (flags['until-time']) {
38
+ deletePayload.untilTime = flags['until-time']
39
+ }
40
+
41
+ // Field locators can be specified either via the --fields-csv flag,
42
+ // or via a combination of the --field-id and --job-base-step-id flags.
43
+ // But one or the other must be present.
44
+ if (flags['fields-csv']) {
45
+ // if fields-csv flag found, then we go with that
46
+ try {
47
+ fs.accessSync(flags['fields-csv'], fs.constants.F_OK | fs.constants.R_OK)
48
+ } catch (error) {
49
+ if (error) {
50
+ if (error.code === 'ENOENT') {
51
+ cli.error(`No file found at --fields-csv=${flags['fields-csv']}`)
52
+ } else {
53
+ cli.error(`User does not have read permissions for file at --fields-csv=${flags['fields-csv']}`)
54
+ }
55
+ }
56
+ }
57
+ deletePayload.fieldCsv = flags['fields-csv']
58
+ } else if (flags['field-id'] && flags['job-base-step-id']) {
59
+ // otherwise if field-id and job-base-step-id are found, use them
60
+ deletePayload.fieldId = flags['field-id']
61
+ deletePayload.jobBaseStepId = flags['job-base-step-id']
62
+ } else {
63
+ // if nothing is found, error out
64
+ cli.error('Must specify either "--fields-csv", or both of "--field-id" and "--job-base-step-id"')
65
+ }
66
+
67
+ // We don't need to worry about errors bubbling up to this level.
68
+ // Since deleteExecData() can attempt to delete multiple field locators' worth of
69
+ // data in a single call, successes and failures are caught and surfaced there.
70
+ cli.action.start('Starting deletion')
71
+ await execDataServiceFn({
72
+ fieldDataClient: this.fieldDataClient,
73
+ render,
74
+ })
75
+ .deleteExecData(deletePayload)
76
+ cli.action.stop()
77
+ }
78
+ }
79
+
80
+ DeleteCommand.description = `Delete execution data corresponding to a specific Input Field on a Job.
81
+
82
+ Fields are uniquely identified by locators, which are combinations of:
83
+ 1. the 'id' of the Field itself, plus
84
+ 2. the 'jobBaseStepId' of the Field's parent Step
85
+
86
+ A single locator can be specified inline, using the arguments --field-id and --job-base-step-id.
87
+ Alternatively, a list of locators can be provided in the form of a CSV file via the --fields-csv argument.
88
+ (More details provided below in the context of the --fields-csv argument.)
89
+
90
+ A time range must be set using the flags:
91
+ 1. 'from-time'
92
+ 2. 'until-time'
93
+ 3. both of the preceding, or
94
+ 4. 'all'
95
+ If no range is set the delete command will not run.
96
+ If 'all' is combined with 'from-time' or 'until-time' the command will not run.
97
+ `
98
+
99
+ DeleteCommand.flags = {
100
+ 'field-id': flags.string({
101
+ char: 'f',
102
+ description: 'The id of the Field to delete execution data from.',
103
+ exclusive: ['fields-csv'],
104
+ }),
105
+
106
+ 'job-base-step-id': flags.string({
107
+ char: 'j',
108
+ description: 'The jobBaseStepId of the Field\'s parent Step.',
109
+ exclusive: ['fields-csv'],
110
+ }),
111
+
112
+ 'fields-csv': flags.string({
113
+ char: 'c',
114
+ description: `The absolute path to a CSV file containing rows of field-id/job-base-step-id pairs.
115
+ The CSV file must not start with a header row (the first line must be the first field locator you wish to delete data for).
116
+ Each row should have as its first element the field id, and as its second element the job-base-step id.
117
+ Example:
118
+ field_id,job_base_step_id
119
+ abc123,def456
120
+ ghi789,jkl012
121
+ `,
122
+ exclusive: ['field-id', 'job-base-step-id'],
123
+ }),
124
+
125
+ 'from-time': flags.integer({
126
+ description: 'Any execution data sent to the server before this timestamp will not be deleted (format: UNIX, seconds since epoch).',
127
+ exclusive: ['all'],
128
+ }),
129
+
130
+ 'until-time': flags.integer({
131
+ description: 'Any execution data sent to the server on or after this timestamp will not be deleted (format: UNIX, seconds since epoch).',
132
+ exclusive: ['all'],
133
+ }),
134
+
135
+ all: flags.boolean({
136
+ char: 'A',
137
+ description: 'When set, deletes all execution data regardless of when it was sent to the server.',
138
+ default: false,
139
+ exclusive: ['from-time', 'until-time'],
140
+ }),
141
+
142
+ force: flags.boolean({
143
+ description: 'When set, skips the "Are you sure" prompt.',
144
+ default: false,
145
+ }),
146
+ }
147
+
148
+ DeleteCommand.hidden = false
149
+
150
+ DeleteCommand.examples = [
151
+ 'parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --all',
152
+ 'parsable-cli exec-data:delete -f abc123 -j def456 -A',
153
+ 'parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789',
154
+ 'parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --until-time=123456789',
155
+ 'parsable-cli exec-data:delete --field-id=abc123 --job-base-step-id=def456 --from-time=123456789 --until-time=123456790',
156
+ 'parsable-cli exec-data:delete --fields-csv=/absolute/path/to/my/file.csv --all',
157
+ 'parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A',
158
+ 'parsable-cli exec-data:delete -c /absolute/path/to/my/file.csv -A --force',
159
+ ]
160
+
161
+ module.exports = DeleteCommand
@@ -0,0 +1,100 @@
1
+ const {flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+
4
+ const BaseCommand = require('../base.js')
5
+ const jobServiceFn = require('../../services/jobs')
6
+
7
+ class CreateCommand extends BaseCommand {
8
+ async run() {
9
+ const {flags} = this.parse(CreateCommand)
10
+ const numberOfJobs = parseInt(flags['number-of-jobs'], 10) || 1
11
+ const templateIds = flags['template-ids'] || ''
12
+ const title = flags.title
13
+
14
+ if (templateIds && templateIds.split(',').length !== numberOfJobs) {
15
+ cli.error('The template-ids count should match with number-of-jobs.')
16
+ }
17
+
18
+ if (title && title.split(',').length !== numberOfJobs) {
19
+ cli.error('The title count should match with number-of-jobs.')
20
+ }
21
+
22
+ cli.action.start('Creating job(s)')
23
+
24
+ const teamId = flags['team-id']
25
+ const numberOfJobsArr = new Array(numberOfJobs).fill(numberOfJobs)
26
+ const templateIdsArr = templateIds.split(',')
27
+ const titleArr = title.split(',')
28
+
29
+ const payloadArr = numberOfJobsArr.map((_, index) => {
30
+ return {
31
+ teamId,
32
+ title: titleArr[index],
33
+ templateId: templateIdsArr[index] || '',
34
+ }
35
+ })
36
+
37
+ const jobs = []
38
+
39
+ for (const payload of payloadArr) {
40
+ // eslint-disable-next-line no-await-in-loop
41
+ const job = await jobServiceFn({
42
+ mothershipClient: this.mothershipClient,
43
+ currentEnv: this.currentEnv,
44
+ }).createJobs(payload)
45
+ jobs.push(job)
46
+ }
47
+
48
+ cli.action.stop()
49
+
50
+ cli.table(jobs, {
51
+ jobId: {
52
+ header: 'Job ID',
53
+ },
54
+ title: {},
55
+ templateId: {
56
+ header: 'Template ID',
57
+ },
58
+ }, {
59
+ ...flags,
60
+ })
61
+ }
62
+ }
63
+
64
+ CreateCommand.description = `Create jobs.
65
+
66
+ Send a request to create a job(s) and assigned templates.
67
+ Currently it only supports on-demand job type.
68
+ `
69
+
70
+ CreateCommand.flags = {
71
+ 'team-id': flags.string({
72
+ description: 'Id of the team who will own the jobs',
73
+ required: true,
74
+ }),
75
+ 'number-of-jobs': flags.string({
76
+ description: 'number of job(s) to be created, will default to 1 if left out',
77
+ }),
78
+ title: flags.string({
79
+ description: 'title of the job(s) and should match to the number of jobs (comma-separated)',
80
+ required: true,
81
+ }),
82
+ 'template-ids': flags.string({
83
+ description: 'template id(s) to be assigned for the created jobs and should match to the number of jobs (comma-separated)',
84
+ required: true,
85
+ }),
86
+ ...cli.table.flags(),
87
+ }
88
+
89
+ CreateCommand.hidden = false
90
+
91
+ CreateCommand.examples = [
92
+ // eslint-disable-next-line quotes
93
+ `parsable-cli jobs:create --team-id=abc123 --title='Job Sample 1'`,
94
+ // eslint-disable-next-line quotes
95
+ `parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2'`,
96
+ // eslint-disable-next-line quotes
97
+ `parsable-cli jobs:create --team-id=abc123 --number-of-jobs=2 --title='Job Sample 1,Job Sample 2' --template-ids=<template_id>,<template_id>`,
98
+ ]
99
+
100
+ module.exports = CreateCommand
@@ -0,0 +1,97 @@
1
+ const {flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+ const debug = require('debug')('app:commands:jobs:DeleteCommand')
4
+
5
+ const BaseCommand = require('../base.js')
6
+ const jobServiceFn = require('../../services/jobs')
7
+
8
+ const confirmationPrompt = `You are about to permanently delete jobs. This cannot be undone. Are you sure you want to proceed?
9
+ If so, type "yes" and return. Otherwise, type anything else or CTRL-c.
10
+ To suppress this step in the future, use the flag --force`
11
+
12
+ const csvParamInfo = `Path to a CSV holding the %JOBTYPE% lookup ids to be deleted.
13
+ There should be no header row in the CSV.
14
+ Each row is a single item: the lookup id (integer or '%JOBTYPE%-123' format key) or database id (UUID) of the %JOBTYPE% to be deleted.
15
+ Maximum file length is 5K rows/%JOBTYPE%s. Beyond that, the CLI may fail to process.
16
+
17
+ Example CSV contents:
18
+ 1234
19
+ 6c807fd4-6594-11eb-ae93-0242ac130002
20
+ 5678
21
+ 75196fd4-6594-11eb-ae93-0242ac130002
22
+ `
23
+ class DeleteCommand extends BaseCommand {
24
+ async run() {
25
+ const {flags} = this.parse(DeleteCommand)
26
+
27
+ const raisePrompt = !flags.force
28
+ if (raisePrompt) {
29
+ const promptResponse = await cli.prompt(confirmationPrompt)
30
+ if (promptResponse === 'yes') {
31
+ cli.info('Confirmed. Proceeding.')
32
+ } else {
33
+ cli.error(`Confirmation response (${promptResponse}) was not "yes". Cancelling deletion.`)
34
+ return
35
+ }
36
+ }
37
+
38
+ if (!flags['jobs-csv'] && !flags['issues-csv']) {
39
+ cli.error('Either --jobs-csv or --issues-csv parameter required')
40
+ }
41
+
42
+ const payload = {
43
+ teamId: flags['team-id'],
44
+ jobsCsv: flags['jobs-csv'],
45
+ issuesCsv: flags['issues-csv'],
46
+ }
47
+ debug(`deletePayload=${JSON.stringify(payload)}`)
48
+
49
+ cli.action.start('Deleting jobs and issues')
50
+ await jobServiceFn({
51
+ adminClient: this.adminClient,
52
+ }).deleteJobs(payload)
53
+
54
+ cli.action.stop()
55
+ }
56
+ }
57
+
58
+ DeleteCommand.description = `Delete jobs and issues listed in CSV files of lookup/database ids.
59
+
60
+ If a job/issue cannot be deleted because it is referenced (depended upon) by another job/issue, then a list of those
61
+ dependents will be output to the files descendant-issues.csv and descendant-jobs.csv accordingly.
62
+ These lists can be fed back into the command on subsequent attempts, issues first and then jobs.
63
+ After the dependents are deleted, you can attempt to delete the original dependency job/issue that failed initially.`
64
+
65
+ DeleteCommand.flags = {
66
+ 'team-id': flags.string({
67
+ char: 't',
68
+ description: 'Id of the team owning the jobs',
69
+ required: true,
70
+ }),
71
+
72
+ 'jobs-csv': flags.string({
73
+ char: 'j',
74
+ description: csvParamInfo.replace(/%JOBTYPE%/g, 'job'),
75
+ }),
76
+
77
+ 'issues-csv': flags.string({
78
+ char: 'i',
79
+ description: csvParamInfo.replace(/%JOBTYPE%/g, 'issue'),
80
+ }),
81
+
82
+ force: flags.boolean({
83
+ description: 'When set, skips the "Are you sure?" prompt',
84
+ default: false,
85
+ }),
86
+ }
87
+
88
+ DeleteCommand.hidden = false
89
+
90
+ DeleteCommand.examples = [
91
+ 'parsable-cli jobs:delete --team-id=abc123 --jobs-csv=path/to/the/file.csv',
92
+ 'parsable-cli jobs:delete --team-id=abc123 --issues-csv=path/to/another/file.csv',
93
+ 'parsable-cli jobs:delete -t abc123 -j path/to/the/file.csv -i path/to/another/file.csv',
94
+ 'parsable-cli jobs:delete -t abc123 -i path/to/the/file.csv --force',
95
+ ]
96
+
97
+ module.exports = DeleteCommand
@@ -0,0 +1,66 @@
1
+ const {flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+
4
+ const BaseCommand = require('../../base.js')
5
+ const copyTemplateStatusServiceFn = require('../../../services/template_status')
6
+ const renderFn = require('../../../services/render')
7
+
8
+ class StatusCommand extends BaseCommand {
9
+ async run() {
10
+ const {flags} = this.parse(StatusCommand)
11
+
12
+ const copyTemplateStatusService = copyTemplateStatusServiceFn({copyTemplateStatusClient: this.copyTemplateStatusClient})
13
+ const render = renderFn({flags})
14
+
15
+ try {
16
+ let answers = flags
17
+ if (!flags['template-id'] && !flags['status-report-id']) {
18
+ // Prompt for required flags
19
+ answers = await copyTemplateStatusService.prompt()
20
+ }
21
+
22
+ cli.action.start('Grabbing status')
23
+ const response = await copyTemplateStatusService.getStatus({statusReportId: answers['status-report-id'], templateId: answers['template-id']})
24
+ cli.action.stop()
25
+ render.renderStatuses(response)
26
+ } catch (error) {
27
+ cli.action.stop('failed!')
28
+ render.renderException(error)
29
+ }
30
+ }
31
+ }
32
+
33
+ StatusCommand.description = `Get the statuses for template copy requests.
34
+ There is one status per template copied.
35
+ Status fields returned include:
36
+ template_id, status (FAILED, SUCCESS, IN_PROGRESS, SCHEDULED), result, start_timestamp, end_timestamp, src_team_id, dest_team_id
37
+ Please use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.
38
+ `
39
+
40
+ StatusCommand.flags = {
41
+ 'status-report-id': flags.string({
42
+ char: 's',
43
+ exclusive: ['template-id'],
44
+ description: 'get statuses for this status report id (id found in output of `parsable-cli template:copy`)',
45
+ }),
46
+ 'template-id': flags.string({
47
+ char: 't',
48
+ exclusive: ['status-report-id'],
49
+ description: 'get statuses for this template id',
50
+ }),
51
+ ...cli.table.flags(),
52
+ }
53
+
54
+ StatusCommand.examples = [
55
+ 'parsable-cli template:copy:status',
56
+ 'parsable-cli template:copy:status --status-report-id <status_report_id>',
57
+ 'parsable-cli template:copy:status -s <status_report_id>',
58
+ 'parsable-cli template:copy:status --template-id <template_id>',
59
+ 'parsable-cli template:copy:status -t <template_id>',
60
+ 'parsable-cli template:copy:status --output json',
61
+ 'parsable-cli template:copy:status --filter status=FAILED',
62
+ ]
63
+
64
+ StatusCommand.hidden = false
65
+
66
+ module.exports = StatusCommand
@@ -0,0 +1,191 @@
1
+ const {flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+ const _get = require('lodash/get')
4
+
5
+ const BaseCommand = require('../base.js')
6
+ const templateCopyServiceFn = require('../../services/template_copy')
7
+ const renderFn = require('../../services/render')
8
+
9
+ class CopyCommand extends BaseCommand {
10
+ async run() {
11
+ const {flags} = this.parse(CopyCommand)
12
+
13
+ const templateCopyService = templateCopyServiceFn({
14
+ copyTemplateClient: this.copyTemplateClient,
15
+ mothershipClient: this.mothershipClient,
16
+ })
17
+ const render = renderFn({flags})
18
+
19
+ try {
20
+ let config
21
+ if (flags.config) {
22
+ cli.action.start('Grabbing config')
23
+ config = await templateCopyService.getConfigFromPath({configPath: flags.config})
24
+ } else {
25
+ // Construct config
26
+ const allPossibleFlags = CopyCommand.flags
27
+ const passedInFlags = flags
28
+
29
+ config = await templateCopyService.getConfigFromFlagsAndPrompts({
30
+ passedInFlags,
31
+ allPossibleFlags,
32
+ defaultApiBase: this.envConfig.defaultApiBase,
33
+ })
34
+ }
35
+
36
+ cli.action.start('Validating config')
37
+ templateCopyService.validateConfigJson({config})
38
+
39
+ cli.action.start('Grabbing src and dest auth token')
40
+ const sourceLoginInfo = _get(config, ['source'])
41
+ const destLoginInfo = _get(config, ['destination'])
42
+ let [sourceAuthToken, destAuthToken] = await Promise.all([
43
+ templateCopyService.getAuthToken(sourceLoginInfo),
44
+ templateCopyService.getAuthToken(destLoginInfo),
45
+ ])
46
+
47
+ const lambdaPayload = templateCopyService.createLambdaPayloadFromConfig({config, sourceAuthToken, destAuthToken})
48
+
49
+ cli.action.start('Sending copy request')
50
+ const statusReportId = await templateCopyService.sendCopyTemplateRequest({lambdaPayload})
51
+ cli.action.stop()
52
+
53
+ render.renderCopyTemplateSuccess(statusReportId)
54
+ } catch (error) {
55
+ cli.action.stop('failed!')
56
+ const statusReportId = _get(error, ['cause', 'response', 'headers', 'status-report-id'])
57
+ if (statusReportId) {
58
+ render.renderCopyTemplateSuccess(statusReportId)
59
+ }
60
+ render.renderException(error)
61
+ }
62
+ }
63
+ }
64
+
65
+ CopyCommand.description = `Send request to copy templates.
66
+ Templates arrive at the destination team in Editing (draft) status.
67
+ We do not support copying archived templates.
68
+ Status report id will be returned unless the request takes over 30 seconds.
69
+ Requests that take over 30 seconds will cause the command to timeout.
70
+ This does not mean the request failed.
71
+ You can still check the statuses by template id: \`parsable-cli template:copy:request --template-id <template_id>\`
72
+ Please use 'parsable-cli login' to specify which environment (staging vs production) to run this command against.
73
+ Reference sheets are automatically copied over if they are associated with the template. Please make sure to include the reference sheet id in the referenceSheetIds config so that templates with reference sheets are copied over correctly.
74
+
75
+ Additional Notes:
76
+ * If you try to copy an object and it has attribute values, then the attribute values only copy over if the destination
77
+ team has custom policies on. Otherwise, for destination teams with custom policies off, we do not copy attribute values
78
+ * Metadata = parameters at the Template level. We do not copy anything Job related (job parameters).
79
+ We copy template metadata values if includeMetadata option is added and if the destination team has the exact
80
+ metadata value matches available.
81
+ `
82
+
83
+ CopyCommand.flags = {
84
+ config: flags.string({
85
+ description: `Path to config json file.
86
+ Config json file should be in the following format:
87
+ {
88
+ "templateIds": [<string>],
89
+ "referenceSheetSetIds": [<string>],
90
+ "source": {
91
+ "teamId": <string>,
92
+ "email": <string>,
93
+ "password": <string>,
94
+ "apiBase": <string>
95
+ },
96
+ "destination": {
97
+ "teamId": <string>,
98
+ "email": <string>,
99
+ "password": <string>,
100
+ "apiBase": <string>
101
+ },
102
+ "options": {
103
+ "includeApplets": <boolean>,
104
+ "includeMetadata": <boolean>,
105
+ "includeProcedureTypes": <boolean>,
106
+ "includeInputTriggers": <boolean>,
107
+ "includeRefSheets": <boolean>
108
+ }
109
+ "shouldPublishTemplates": <boolean>
110
+ }
111
+ `,
112
+ }),
113
+ 'template-ids': flags.string({
114
+ description: 'template id(s) from source team to copy to destination team (comma-separated)',
115
+ exclusive: ['config'],
116
+ }),
117
+ 'reference-sheet-set-ids': flags.string({
118
+ description: 'reference sheet set id(s) from source team to copy to destination team (comma-separated)',
119
+ // default: '',
120
+ exclusive: ['config'],
121
+ }),
122
+ 'src-team-id': flags.string({
123
+ description: 'source team id of template(s) to copy from',
124
+ exclusive: ['config'],
125
+ }),
126
+ 'src-email': flags.string({
127
+ description: 'email of admin user in the source team',
128
+ exclusive: ['config'],
129
+ }),
130
+ 'src-password': flags.string({
131
+ description: 'password of admin user in the source team',
132
+ exclusive: ['config'],
133
+ }),
134
+ 'src-api-base': flags.string({
135
+ description: 'hostname of the source team environment',
136
+ exclusive: ['config'],
137
+ }),
138
+ 'dest-team-id': flags.string({
139
+ description: 'destination team id for template(s) to copy into',
140
+ exclusive: ['config'],
141
+ }),
142
+ 'dest-email': flags.string({
143
+ description: 'email of admin user in the destination team',
144
+ exclusive: ['config'],
145
+ }),
146
+ 'dest-password': flags.string({
147
+ description: 'password of admin user in the destination team',
148
+ exclusive: ['config'],
149
+ }),
150
+ 'dest-api-base': flags.string({
151
+ description: 'hostname of the destination team environment',
152
+ exclusive: ['config'],
153
+ }),
154
+ 'include-applets': flags.boolean({
155
+ description: 'copy applets over',
156
+ exclusive: ['config'],
157
+ }),
158
+ 'include-metadata': flags.boolean({
159
+ description: 'copy metadata over',
160
+ exclusive: ['config'],
161
+ }),
162
+ 'include-procedure-types': flags.boolean({
163
+ description: 'copy procedure types over',
164
+ exclusive: ['config'],
165
+ }),
166
+ 'include-input-triggers': flags.boolean({
167
+ description: 'copy input triggers over',
168
+ exclusive: ['config'],
169
+ }),
170
+ 'include-refsheets': flags.boolean({
171
+ description: 'copy reference sheets over',
172
+ exclusive: ['config'],
173
+ }),
174
+ 'should-publish-templates': flags.boolean({
175
+ description: 'copied templates should be published',
176
+ exclusive: ['config'],
177
+ default: false,
178
+ }),
179
+ ...cli.table.flags(),
180
+ }
181
+
182
+ CopyCommand.hidden = false
183
+
184
+ CopyCommand.examples = [
185
+ 'parsable-cli template:copy',
186
+ 'parsable-cli template:copy --config ./config.json',
187
+ 'parsable-cli template:copy --should-publish-templates',
188
+ 'parsable-cli template:copy --template-ids <template_id>,<template_id>',
189
+ ]
190
+
191
+ module.exports = CopyCommand
@@ -0,0 +1,40 @@
1
+ const {cli} = require('cli-ux')
2
+
3
+ const Config = function (passedInEnv) {
4
+ const DEFAULT_ENV = 'staging'
5
+
6
+ const env = passedInEnv || DEFAULT_ENV
7
+
8
+ const envConf = {
9
+ staging: {
10
+ copyTemplateService: {
11
+ url: 'https://oczx952hj1.execute-api.us-west-2.amazonaws.com/v2/CopyTemplateService',
12
+ // NOTE: this is the url nexus is hitting...
13
+ // url: 'https://oczx952hj1.execute-api.us-west-2.amazonaws.com/default/CopyTemplateService'
14
+ },
15
+ copyTemplateStatus: {
16
+ urlPrefix: 'https://oczx952hj1.execute-api.us-west-2.amazonaws.com/v2/status/',
17
+ // NOTE: this is the url nexus is hitting...
18
+ // url_prefix: 'https://oczx952hj1.execute-api.us-west-2.amazonaws.com/default/status/requests/'
19
+ },
20
+ defaultApiBase: 'https://api.staging.parsable.net',
21
+ },
22
+ production: {
23
+ copyTemplateService: {
24
+ url: 'https://kbua6l2pwl.execute-api.us-west-2.amazonaws.com/v2/CopyTemplateService',
25
+ },
26
+ copyTemplateStatus: {
27
+ urlPrefix: 'https://kbua6l2pwl.execute-api.us-west-2.amazonaws.com/v2/status',
28
+ },
29
+ defaultApiBase: 'https://api.parsable.net',
30
+ },
31
+ }
32
+
33
+ if (!envConf[env]) {
34
+ cli.error(`Environment config not found for "${env}"`)
35
+ }
36
+
37
+ return envConf[env]
38
+ }
39
+
40
+ module.exports = Config
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('@oclif/command')