@unito/integration-cli 1.3.5 → 1.5.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.
@@ -1503,9 +1503,9 @@
1503
1503
  }
1504
1504
  },
1505
1505
  "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
1506
- "version": "5.0.5",
1507
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
1508
- "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
1506
+ "version": "5.0.6",
1507
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
1508
+ "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
1509
1509
  "dev": true,
1510
1510
  "license": "MIT",
1511
1511
  "dependencies": {
@@ -3280,9 +3280,9 @@
3280
3280
  }
3281
3281
  },
3282
3282
  "node_modules/qs": {
3283
- "version": "6.15.0",
3284
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz",
3285
- "integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==",
3283
+ "version": "6.15.2",
3284
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
3285
+ "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
3286
3286
  "license": "BSD-3-Clause",
3287
3287
  "dependencies": {
3288
3288
  "side-channel": "^1.1.0"
@@ -60,22 +60,10 @@
60
60
  "$ref": "https://unito.io/integration_cli/authorization.schema.json"
61
61
  }
62
62
  },
63
- "testAccounts": {
63
+ "testAccount": {
64
64
  "type": "object",
65
- "description": "The test accounts of the integration",
66
- "additionalProperties": false,
67
- "properties": {
68
- "development": {
69
- "type": "object",
70
- "description": "Test account for local development",
71
- "additionalProperties": true
72
- },
73
- "compliance": {
74
- "type": "object",
75
- "description": "Test account for compliance tests",
76
- "additionalProperties": true
77
- }
78
- }
65
+ "description": "The test account of the integration",
66
+ "additionalProperties": true
79
67
  },
80
68
  "secrets": {
81
69
  "type": "object",
@@ -23,7 +23,7 @@ class Activity extends baseCommand_1.BaseCommand {
23
23
  environment: core_1.Flags.custom({
24
24
  description: 'the environment of the platform',
25
25
  options: Object.values(GlobalConfiguration.Environment),
26
- default: GlobalConfiguration.Environment.Production,
26
+ default: GlobalConfiguration.Environment.Local,
27
27
  })(),
28
28
  follow: core_1.Flags.boolean({
29
29
  char: 'f',
@@ -45,14 +45,13 @@ class Activity extends baseCommand_1.BaseCommand {
45
45
  const { flags } = await this.parse(Activity);
46
46
  // Read the configurations.
47
47
  const globalConfiguration = await GlobalConfiguration.read(this.config.configDir);
48
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
49
- const integrationConfiguration = await IntegrationConfiguration.getConfiguration(environment);
48
+ const integrationConfiguration = await IntegrationConfiguration.getConfiguration(flags.environment);
50
49
  // Choose the right API key for the environment.
51
50
  let apiKey = undefined;
52
- if (environment === GlobalConfiguration.Environment.Local) {
51
+ if (flags.environment === GlobalConfiguration.Environment.Local) {
53
52
  apiKey = globalConfiguration.apiKeyLocal;
54
53
  }
55
- else if (environment === GlobalConfiguration.Environment.Staging) {
54
+ else if (flags.environment === GlobalConfiguration.Environment.Staging) {
56
55
  apiKey = globalConfiguration.apiKeyStaging;
57
56
  }
58
57
  else {
@@ -60,7 +59,7 @@ class Activity extends baseCommand_1.BaseCommand {
60
59
  }
61
60
  // Setup the platform client.
62
61
  IntegrationsPlatform.setApiKey(apiKey);
63
- IntegrationsPlatform.setEnvironment(environment);
62
+ IntegrationsPlatform.setEnvironment(flags.environment);
64
63
  core_1.ux.action.start('Finding the integration', undefined, { stdout: true });
65
64
  let integration;
66
65
  try {
@@ -9,7 +9,6 @@ export default class Dev extends BaseCommand<typeof Dev> {
9
9
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
10
  'credential-payload': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  'credential-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
- 'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
13
12
  'read-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
13
  timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
15
14
  crawlMode: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -25,7 +25,7 @@ class Dev extends baseCommand_1.BaseCommand {
25
25
  environment: core_1.Flags.custom({
26
26
  description: 'the environment of the platform',
27
27
  options: Object.values(GlobalConfiguration.Environment),
28
- default: GlobalConfiguration.Environment.Production,
28
+ default: GlobalConfiguration.Environment.Local,
29
29
  })(),
30
30
  verbose: core_1.Flags.boolean({
31
31
  description: 'output more (debug) information',
@@ -39,11 +39,6 @@ class Dev extends baseCommand_1.BaseCommand {
39
39
  description: '(advanced) credential to use.',
40
40
  exclusive: ['credential-payload'],
41
41
  }),
42
- 'test-account': core_1.Flags.string({
43
- description: 'test account to use.',
44
- options: Object.values(configuration_1.CredentialScope),
45
- default: configuration_1.CredentialScope.DEVELOPMENT,
46
- }),
47
42
  'read-only': core_1.Flags.boolean({
48
43
  description: 'whether or not to only perform read operations',
49
44
  allowNo: true,
@@ -95,12 +90,11 @@ class Dev extends baseCommand_1.BaseCommand {
95
90
  core_1.ux.action.stop();
96
91
  }
97
92
  // Resolve the configuration.
98
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
99
- const configuration = await (0, configuration_1.getConfiguration)(environment, flags['config-path']);
93
+ const configuration = await (0, configuration_1.getConfiguration)(flags.environment, flags['config-path']);
100
94
  let credentialPayload = '{}';
101
95
  let readOnly = flags['read-only'] ?? false;
102
96
  if (flags['credential-id']) {
103
- const credential = await (0, credentials_1.fetchCredential)(environment, this.config.configDir, flags['credential-id']);
97
+ const credential = await (0, credentials_1.fetchCredential)(flags.environment, this.config.configDir, flags['credential-id']);
104
98
  credentialPayload = JSON.stringify({
105
99
  ...credential.payload,
106
100
  unitoCredentialId: credential.id,
@@ -112,27 +106,24 @@ class Dev extends baseCommand_1.BaseCommand {
112
106
  else if (flags['credential-payload']) {
113
107
  credentialPayload = flags['credential-payload'];
114
108
  }
115
- else {
116
- const credentials = configuration.testAccounts?.[flags['test-account']];
117
- if (credentials) {
118
- const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, credentials);
119
- if (decryptedEntries.failed.length) {
120
- throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
121
- }
122
- credentialPayload = JSON.stringify({
123
- ...decryptedEntries.successful,
124
- unitoCredentialId: flags['test-account'],
125
- unitoUserId: flags['test-account'],
126
- });
109
+ else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
110
+ const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.testAccount);
111
+ if (decryptedEntries.failed.length) {
112
+ throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), flags.environment);
127
113
  }
114
+ credentialPayload = JSON.stringify({
115
+ ...decryptedEntries.successful,
116
+ unitoCredentialId: 'testAccount',
117
+ unitoUserId: 'testAccount',
118
+ });
128
119
  }
129
120
  // Load secrets.
130
- const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
121
+ const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.secrets ?? {});
131
122
  if (failedSecrets.length) {
132
- throw new errors_1.EntryDecryptionError(failedSecrets.at(0), environment);
123
+ throw new errors_1.EntryDecryptionError(failedSecrets.at(0), flags.environment);
133
124
  }
134
125
  // Load environment variables.
135
- const { successful: environmentVariables, failed: failedEnvironmentVariables } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.environmentVariables ?? {});
126
+ const { successful: environmentVariables, failed: failedEnvironmentVariables } = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.environmentVariables ?? {});
136
127
  for (const environmentVariable of failedEnvironmentVariables) {
137
128
  if (!process.env[environmentVariable]) {
138
129
  core_1.ux.log();
@@ -18,7 +18,7 @@ class Encrypt extends baseCommand_1.BaseCommand {
18
18
  environment: core_1.Flags.custom({
19
19
  description: 'the environment of the platform',
20
20
  options: Object.values(GlobalConfiguration.Environment),
21
- default: GlobalConfiguration.Environment.Production,
21
+ default: GlobalConfiguration.Environment.Local,
22
22
  })(),
23
23
  sensitive: core_1.Flags.boolean({
24
24
  description: 'once encrypted, sensitive data cannot be decrypted',
@@ -37,9 +37,8 @@ class Encrypt extends baseCommand_1.BaseCommand {
37
37
  const { flags } = await this.parse(Encrypt);
38
38
  // Read the configurations.
39
39
  const globalConfiguration = await GlobalConfiguration.read(this.config.configDir);
40
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
41
- const integrationConfiguration = await IntegrationConfiguration.getConfiguration(environment);
42
- await (0, integrationsPlatform_1.validateAuthenticated)(globalConfiguration, environment);
40
+ const integrationConfiguration = await IntegrationConfiguration.getConfiguration(flags.environment);
41
+ await (0, integrationsPlatform_1.validateAuthenticated)(globalConfiguration, flags.environment);
43
42
  const { data } = await inquirer_1.default.prompt({
44
43
  name: 'data',
45
44
  message: 'Enter text to encrypt',
@@ -11,7 +11,6 @@ export default class Graph extends BaseCommand<typeof Graph> {
11
11
  path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  port: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  environment: import("@oclif/core/lib/interfaces").OptionFlag<GlobalConfiguration.Environment, import("@oclif/core/lib/interfaces").CustomOptions>;
14
- 'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
15
14
  'credential-payload': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
15
  'credential-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
17
16
  'config-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -55,13 +55,8 @@ class Graph extends baseCommand_1.BaseCommand {
55
55
  environment: core_1.Flags.custom({
56
56
  description: 'the environment of the platform',
57
57
  options: Object.values(GlobalConfiguration.Environment),
58
- default: GlobalConfiguration.Environment.Production,
58
+ default: GlobalConfiguration.Environment.Local,
59
59
  })(),
60
- 'test-account': core_1.Flags.string({
61
- description: 'test account to use',
62
- options: Object.values(configuration_1.CredentialScope),
63
- default: configuration_1.CredentialScope.DEVELOPMENT,
64
- }),
65
60
  'credential-payload': core_1.Flags.string({
66
61
  description: '(advanced) credential payload to use.',
67
62
  exclusive: ['credential-id'],
@@ -110,12 +105,11 @@ class Graph extends baseCommand_1.BaseCommand {
110
105
  if (operation === 'deleteItem' && (flags.body || flags['body-file'])) {
111
106
  this.error('--body and --body-file are not supported for deleteItem', { exit: 1 });
112
107
  }
113
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
114
- const configuration = await (0, configuration_1.getConfiguration)(environment, flags['config-path']);
108
+ const configuration = await (0, configuration_1.getConfiguration)(flags.environment, flags['config-path']);
115
109
  // Credential resolution — identical to dev.ts
116
110
  let credentialPayload = '{}';
117
111
  if (flags['credential-id']) {
118
- const credential = await (0, credentials_1.fetchCredential)(environment, this.config.configDir, flags['credential-id']);
112
+ const credential = await (0, credentials_1.fetchCredential)(flags.environment, this.config.configDir, flags['credential-id']);
119
113
  credentialPayload = JSON.stringify({
120
114
  ...credential.payload,
121
115
  unitoCredentialId: credential.id,
@@ -125,24 +119,21 @@ class Graph extends baseCommand_1.BaseCommand {
125
119
  else if (flags['credential-payload']) {
126
120
  credentialPayload = flags['credential-payload'];
127
121
  }
128
- else {
129
- const credentials = configuration.testAccounts?.[flags['test-account']];
130
- if (credentials) {
131
- const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, credentials);
132
- if (decryptedEntries.failed.length) {
133
- throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
134
- }
135
- credentialPayload = JSON.stringify({
136
- ...decryptedEntries.successful,
137
- unitoCredentialId: flags['test-account'],
138
- unitoUserId: flags['test-account'],
139
- });
122
+ else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
123
+ const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.testAccount);
124
+ if (decryptedEntries.failed.length) {
125
+ throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), flags.environment);
140
126
  }
127
+ credentialPayload = JSON.stringify({
128
+ ...decryptedEntries.successful,
129
+ unitoCredentialId: 'testAccount',
130
+ unitoUserId: 'testAccount',
131
+ });
141
132
  }
142
133
  // Load secrets — identical to dev.ts
143
- const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
134
+ const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.secrets ?? {});
144
135
  if (failedSecrets.length) {
145
- throw new errors_1.EntryDecryptionError(failedSecrets.at(0), environment);
136
+ throw new errors_1.EntryDecryptionError(failedSecrets.at(0), flags.environment);
146
137
  }
147
138
  // Build Unito request headers.
148
139
  // Encoding: base64(JSON.stringify(payload)) — same as integrationDebugger/src/services/crawlerDriver.ts line 424.
@@ -17,7 +17,7 @@ class Invite extends baseCommand_1.BaseCommand {
17
17
  environment: core_1.Flags.custom({
18
18
  description: 'the environment of the platform',
19
19
  options: Object.values(GlobalConfiguration.Environment),
20
- default: GlobalConfiguration.Environment.Production,
20
+ default: GlobalConfiguration.Environment.Local,
21
21
  })(),
22
22
  };
23
23
  async catch(error) {
@@ -32,14 +32,13 @@ class Invite extends baseCommand_1.BaseCommand {
32
32
  const { flags } = await this.parse(Invite);
33
33
  // Read the configurations.
34
34
  const globalConfiguration = await GlobalConfiguration.read(this.config.configDir);
35
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
36
- const integrationConfiguration = await IntegrationConfiguration.getConfiguration(environment);
35
+ const integrationConfiguration = await IntegrationConfiguration.getConfiguration(flags.environment);
37
36
  // Choose the right API key for the environment.
38
37
  let apiKey = undefined;
39
- if (environment === GlobalConfiguration.Environment.Local) {
38
+ if (flags.environment === GlobalConfiguration.Environment.Local) {
40
39
  apiKey = globalConfiguration.apiKeyLocal;
41
40
  }
42
- else if (environment === GlobalConfiguration.Environment.Staging) {
41
+ else if (flags.environment === GlobalConfiguration.Environment.Staging) {
43
42
  apiKey = globalConfiguration.apiKeyStaging;
44
43
  }
45
44
  else {
@@ -47,7 +46,7 @@ class Invite extends baseCommand_1.BaseCommand {
47
46
  }
48
47
  // Setup the platform client.
49
48
  IntegrationsPlatform.setApiKey(apiKey);
50
- IntegrationsPlatform.setEnvironment(environment);
49
+ IntegrationsPlatform.setEnvironment(flags.environment);
51
50
  const { email } = await inquirer_1.default.prompt([
52
51
  {
53
52
  name: 'email',
@@ -16,7 +16,7 @@ class Login extends baseCommand_1.BaseCommand {
16
16
  environment: core_1.Flags.custom({
17
17
  description: 'the environment of the platform',
18
18
  options: Object.values(GlobalConfiguration.Environment),
19
- default: GlobalConfiguration.Environment.Production,
19
+ default: GlobalConfiguration.Environment.Local,
20
20
  })(),
21
21
  };
22
22
  async catch(error) {
@@ -30,7 +30,6 @@ class Login extends baseCommand_1.BaseCommand {
30
30
  const { flags } = await this.parse(Login);
31
31
  // Read the current global configuration.
32
32
  const configuration = await GlobalConfiguration.read(this.config.configDir);
33
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
34
33
  // Inquire for the API key.
35
34
  let apiKey = undefined;
36
35
  try {
@@ -49,7 +48,7 @@ class Login extends baseCommand_1.BaseCommand {
49
48
  // Retrieve the user's profile.
50
49
  core_1.ux.action.start('Log in', undefined, { stdout: true });
51
50
  let profile = undefined;
52
- IntegrationsPlatform.setEnvironment(environment);
51
+ IntegrationsPlatform.setEnvironment(flags.environment);
53
52
  IntegrationsPlatform.setApiKey(apiKey);
54
53
  try {
55
54
  profile = await IntegrationsPlatform.getProfile();
@@ -61,10 +60,10 @@ class Login extends baseCommand_1.BaseCommand {
61
60
  core_1.ux.action.stop();
62
61
  core_1.ux.log([chalk_1.default.greenBright('Hello'), gradient.fruit(profile?.email ?? ''), chalk_1.default.greenBright('!')].join(' '));
63
62
  // Set the API key in the global configuration.
64
- if (environment === GlobalConfiguration.Environment.Local) {
63
+ if (flags.environment === GlobalConfiguration.Environment.Local) {
65
64
  configuration.apiKeyLocal = apiKey;
66
65
  }
67
- else if (environment === GlobalConfiguration.Environment.Staging) {
66
+ else if (flags.environment === GlobalConfiguration.Environment.Staging) {
68
67
  configuration.apiKeyStaging = apiKey;
69
68
  }
70
69
  else {
@@ -5,7 +5,6 @@ export default class Oauth2 extends Command {
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- 'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
9
8
  environment: import("@oclif/core/lib/interfaces").OptionFlag<Environment, import("@oclif/core/lib/interfaces").CustomOptions>;
10
9
  reauth: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
10
  'config-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -11,25 +11,17 @@ const errors_1 = require("../errors");
11
11
  const globalConfiguration_1 = require("../resources/globalConfiguration");
12
12
  const decryption_1 = require("../resources/decryption");
13
13
  class Oauth2 extends core_1.Command {
14
- static summary = `Perform an OAuth2 workflow to either populate or refresh a test account's credentials.`;
15
- static description = `The Oauth2 command allows you to perform an OAuth2 workflow to populate the specified test account's accessToken and refreshToken to be used by the 'test' and 'dev' commands.
14
+ static summary = `Perform an OAuth2 workflow to either populate or refresh the test account's credentials.`;
15
+ static description = `The Oauth2 command allows you to perform an OAuth2 workflow to populate the test account's accessToken and refreshToken to be used by the 'test' and 'dev' commands.
16
16
 
17
- If the test-account is already populated, the command will refresh the credentials if the refresh token is available.
17
+ If the test account is already populated, the command will refresh the credentials if the refresh token is available.
18
18
  If you want to force a new OAuth2 flow to change the connected account or something else, use the --reauth flag.`;
19
- static examples = [
20
- '<%= config.bin %> <%= command.id %>',
21
- '<%= config.bin %> <%= command.id %> --reauth --test-account=compliance',
22
- ];
19
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --reauth'];
23
20
  static flags = {
24
- 'test-account': core_1.Flags.string({
25
- description: 'Test account to use.',
26
- options: Object.values(configuration_1.CredentialScope),
27
- default: configuration_1.CredentialScope.DEVELOPMENT,
28
- }),
29
21
  environment: core_1.Flags.custom({
30
22
  description: 'the environment of the platform',
31
23
  options: Object.values(globalConfiguration_1.Environment),
32
- default: globalConfiguration_1.Environment.Production,
24
+ default: globalConfiguration_1.Environment.Local,
33
25
  })(),
34
26
  reauth: core_1.Flags.boolean({
35
27
  description: `triggers a new oauth2 flow to overwrite the test account's current credentials`,
@@ -55,9 +47,8 @@ class Oauth2 extends core_1.Command {
55
47
  }
56
48
  async run() {
57
49
  const { flags } = await this.parse(Oauth2);
58
- const environment = flags.environment ?? globalConfiguration_1.Environment.Production;
59
50
  const customConfigPath = flags['config-path'];
60
- const configuration = await (0, configuration_1.getConfiguration)(environment, customConfigPath);
51
+ const configuration = await (0, configuration_1.getConfiguration)(flags.environment, customConfigPath);
61
52
  // First check for development oauth2 authorization scheme
62
53
  let oauth2 = configuration.authorizations?.find(authorization => authorization.method === configurationTypes_1.Method.OAUTH2 && authorization.development)?.oauth2;
63
54
  // Try for any oauth2 authorization scheme if there was no development one
@@ -68,30 +59,20 @@ class Oauth2 extends core_1.Command {
68
59
  throw new errors_1.MissingAuth2AuthorizationError();
69
60
  }
70
61
  // Decrypt any encrypted oauth2 fields (mainly clientSecret)
71
- const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, oauth2);
62
+ const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, oauth2);
72
63
  if (decryptedEntries.failed.length) {
73
- throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
64
+ throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), flags.environment);
74
65
  }
75
66
  oauth2 = decryptedEntries.successful;
76
- const testAccount = flags['test-account'];
77
- const testAccountCredentials = configuration.testAccounts?.[testAccount];
78
- const testAccountsToRefresh = new Set([testAccount]);
79
- // Figure out if we want to refresh other test account at the same time (like if they currently have the same values)
80
- for (const [account, accountCredentials] of Object.entries(configuration.testAccounts ?? {})) {
81
- if (!testAccountsToRefresh.has(account) &&
82
- accountCredentials?.accessToken === testAccountCredentials?.accessToken &&
83
- accountCredentials?.refreshToken === testAccountCredentials?.refreshToken) {
84
- testAccountsToRefresh.add(account);
85
- }
86
- }
67
+ const testAccountCredentials = configuration.testAccount;
87
68
  let decryptionResult;
88
69
  if (testAccountCredentials) {
89
- decryptionResult = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, testAccountCredentials);
70
+ decryptionResult = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, testAccountCredentials);
90
71
  }
91
72
  let credentials;
92
73
  if (!testAccountCredentials?.accessToken || flags.reauth) {
93
- core_1.ux.log(`Starting OAuth2 flow for test account: ${testAccount}`);
94
- credentials = await Oauth2Resource.performOAuth2Flow(oauth2, environment, testAccountCredentials);
74
+ core_1.ux.log(`Starting OAuth2 flow for test account`);
75
+ credentials = await Oauth2Resource.performOAuth2Flow(oauth2, flags.environment, testAccountCredentials);
95
76
  core_1.ux.log(`OAuth2 flow... Done`);
96
77
  }
97
78
  else {
@@ -100,8 +81,8 @@ class Oauth2 extends core_1.Command {
100
81
  return;
101
82
  }
102
83
  const refreshToken = decryptionResult?.successful.refreshToken;
103
- core_1.ux.action.start(`Refreshing test account ${testAccount}`, undefined, { stdout: true });
104
- credentials = await Oauth2Resource.updateToken(oauth2, refreshToken, decryptionResult?.successful, environment);
84
+ core_1.ux.action.start(`Refreshing test account`, undefined, { stdout: true });
85
+ credentials = await Oauth2Resource.updateToken(oauth2, refreshToken, decryptionResult?.successful, flags.environment);
105
86
  // If provider response doesn't contain a new refresh token, use the existing one
106
87
  credentials.refreshToken = credentials.refreshToken ?? refreshToken;
107
88
  core_1.ux.action.stop();
@@ -111,12 +92,9 @@ class Oauth2 extends core_1.Command {
111
92
  if (credentials.refreshToken) {
112
93
  credentials.refreshToken = (await IntegrationsPlatform.encryptData(configuration.name, credentials.refreshToken, false)).encryptedData;
113
94
  }
114
- // Save credentials for all test accounts needing refresh
115
- for (const account of testAccountsToRefresh) {
116
- core_1.ux.action.start(`Saving credentials for account: ${account}`, undefined, { stdout: true });
117
- await (0, configuration_1.writeTestAccount)(configuration, environment, customConfigPath, credentials, account);
118
- core_1.ux.action.stop();
119
- }
95
+ core_1.ux.action.start(`Saving credentials for test account`, undefined, { stdout: true });
96
+ await (0, configuration_1.writeTestAccount)(configuration, flags.environment, customConfigPath, credentials);
97
+ core_1.ux.action.stop();
120
98
  }
121
99
  }
122
100
  exports.default = Oauth2;
@@ -26,7 +26,7 @@ class Publish extends baseCommand_1.BaseCommand {
26
26
  environment: core_1.Flags.custom({
27
27
  description: 'the environment of the platform',
28
28
  options: Object.values(GlobalConfiguration.Environment),
29
- default: GlobalConfiguration.Environment.Production,
29
+ default: GlobalConfiguration.Environment.Local,
30
30
  })(),
31
31
  'registry-only': core_1.Flags.boolean({
32
32
  description: 'only update the registry without publishing code',
@@ -80,7 +80,6 @@ class Publish extends baseCommand_1.BaseCommand {
80
80
  const { flags } = await this.parse(Publish);
81
81
  // Read the configurations.
82
82
  const globalConfiguration = await GlobalConfiguration.read(this.config.configDir);
83
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
84
83
  // Runtime guards. oclif's dependsOn/relationships can't be used for the
85
84
  // "--visibility=public requires --preview" rule because --preview has
86
85
  // `default: false` and oclif treats defaulted booleans as "present".
@@ -89,7 +88,7 @@ class Publish extends baseCommand_1.BaseCommand {
89
88
  core_1.ux.log(chalk_1.default.redBright('--visibility=public is only supported in combination with --preview.'));
90
89
  this.exit(-1);
91
90
  }
92
- if (environment === GlobalConfiguration.Environment.Production) {
91
+ if (flags.environment === GlobalConfiguration.Environment.Production) {
93
92
  core_1.ux.log(chalk_1.default.redBright('--visibility=public is not supported on --environment=production. ' +
94
93
  'Publish privately first; changing visibility on production is handled by a separate process.'));
95
94
  this.exit(-1);
@@ -98,11 +97,11 @@ class Publish extends baseCommand_1.BaseCommand {
98
97
  if (flags['display-name'] !== undefined &&
99
98
  !flags.preview &&
100
99
  !flags['live-preview'] &&
101
- environment !== GlobalConfiguration.Environment.Local) {
100
+ flags.environment !== GlobalConfiguration.Environment.Local) {
102
101
  core_1.ux.log(chalk_1.default.redBright('--display-name is only supported with --preview, --live-preview, or --environment=local.'));
103
102
  this.exit(-1);
104
103
  }
105
- const integrationConfiguration = await IntegrationConfiguration.getConfiguration(environment, flags['config-path']);
104
+ const integrationConfiguration = await IntegrationConfiguration.getConfiguration(flags.environment, flags['config-path']);
106
105
  if (flags['display-name'] !== undefined) {
107
106
  // Set the base display name. Mode-specific suffixes ("Preview - {hash}", "Live Preview - {hash}")
108
107
  // are appended later inside the corresponding preview methods.
@@ -115,7 +114,7 @@ class Publish extends baseCommand_1.BaseCommand {
115
114
  integrationConfiguration.authorizations = integrationConfiguration.authorizations.filter(authorization => !authorization.development);
116
115
  }
117
116
  // Login to the platform.
118
- await (0, integrationsPlatform_1.validateAuthenticated)(globalConfiguration, environment);
117
+ await (0, integrationsPlatform_1.validateAuthenticated)(globalConfiguration, flags.environment);
119
118
  // Package the integration.
120
119
  tmp_1.default.setGracefulCleanup();
121
120
  if (flags['live-preview']) {
@@ -123,7 +122,7 @@ class Publish extends baseCommand_1.BaseCommand {
123
122
  }
124
123
  else if (flags['registry-only']) {
125
124
  let proceed = true;
126
- if (!flags.force && environment === GlobalConfiguration.Environment.Production) {
125
+ if (!flags.force && flags.environment === GlobalConfiguration.Environment.Production) {
127
126
  ({ proceed } = await inquirer_1.default.prompt({
128
127
  name: 'proceed',
129
128
  message: '🙈🔫 You are about to update an integration in production directly. This is unusual, you should go through the normal publish and review process, are you sure you want to proceed?',
@@ -131,7 +130,7 @@ class Publish extends baseCommand_1.BaseCommand {
131
130
  }));
132
131
  }
133
132
  if (proceed) {
134
- core_1.ux.log(`🙈 Hang on tight, updating Integration ${integrationConfiguration.name} information's in ${environment}!`);
133
+ core_1.ux.log(`🙈 Hang on tight, updating Integration ${integrationConfiguration.name} information's in ${flags.environment}!`);
135
134
  await this.updateRegistry(integrationConfiguration);
136
135
  }
137
136
  else {
@@ -33,12 +33,8 @@ class SchemaSnapshot extends baseCommand_1.BaseCommand {
33
33
  environment: core_1.Flags.custom({
34
34
  description: 'the environment of the platform',
35
35
  options: Object.values(GlobalConfiguration.Environment),
36
- default: GlobalConfiguration.Environment.Production,
36
+ default: GlobalConfiguration.Environment.Local,
37
37
  })(),
38
- 'test-account': core_1.Flags.string({
39
- description: 'test account to use',
40
- default: configuration_1.CredentialScope.DEVELOPMENT,
41
- }),
42
38
  'config-path': core_1.Flags.string({
43
39
  description: 'relative path to a custom ".unito.json" file',
44
40
  }),
@@ -64,8 +60,7 @@ class SchemaSnapshot extends baseCommand_1.BaseCommand {
64
60
  async run() {
65
61
  (0, integrations_1.validateIsIntegrationDirectory)();
66
62
  const { flags } = await this.parse(SchemaSnapshot);
67
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
68
- const config = await (0, configuration_1.getConfiguration)(environment, flags['config-path']);
63
+ const config = await (0, configuration_1.getConfiguration)(flags.environment, flags['config-path']);
69
64
  if (!flags['skip-install']) {
70
65
  core_1.ux.action.start('Installing NPM dependencies', undefined, { stdout: true });
71
66
  child_process_1.default.execSync('npm install', {
@@ -75,21 +70,20 @@ class SchemaSnapshot extends baseCommand_1.BaseCommand {
75
70
  core_1.ux.action.stop();
76
71
  }
77
72
  // Resolve credentials.
78
- const testAccount = flags['test-account'];
79
- const credentials = config.testAccounts?.[testAccount] || {};
80
- const decryptedCreds = await (0, decryption_1.decryptEntries)(config.name, environment, this.config.configDir, credentials);
73
+ const credentials = config.testAccount ?? {};
74
+ const decryptedCreds = await (0, decryption_1.decryptEntries)(config.name, flags.environment, this.config.configDir, credentials);
81
75
  if (decryptedCreds.failed.length) {
82
- throw new errors_1.EntryDecryptionError(decryptedCreds.failed.at(0), environment);
76
+ throw new errors_1.EntryDecryptionError(decryptedCreds.failed.at(0), flags.environment);
83
77
  }
84
78
  const credentialPayload = {
85
79
  ...decryptedCreds.successful,
86
- unitoCredentialId: flags['test-account'],
87
- unitoUserId: flags['test-account'],
80
+ unitoCredentialId: 'testAccount',
81
+ unitoUserId: 'testAccount',
88
82
  };
89
83
  // Load secrets.
90
- const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(config.name, environment, this.config.configDir, config.secrets ?? {});
84
+ const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(config.name, flags.environment, this.config.configDir, config.secrets ?? {});
91
85
  if (failedSecrets.length) {
92
- throw new errors_1.EntryDecryptionError(failedSecrets.at(0), environment);
86
+ throw new errors_1.EntryDecryptionError(failedSecrets.at(0), flags.environment);
93
87
  }
94
88
  core_1.ux.action.start('Starting integration', undefined, { stdout: true });
95
89
  const integrationPort = String(flags.port);