zapier-platform-cli 12.0.2 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,32 @@
1
1
  const ZapierBaseCommand = require('../../ZapierBaseCommand');
2
2
  const { cyan } = require('colors/safe');
3
3
  const { buildFlags } = require('../../buildFlags');
4
- const {
5
- callAPI,
6
- getWritableApp,
7
- listEndpointMulti,
8
- } = require('../../../utils/api');
4
+ const { callAPI, getWritableApp } = require('../../../utils/api');
9
5
  const { BASE_ENDPOINT } = require('../../../constants');
10
-
11
- const roleName = (role) => (role === 'collaborator' ? 'admin' : 'subscriber');
6
+ const { listTeamMembers, transformUserRole } = require('../../../utils/team');
12
7
 
13
8
  class TeamRemoveCommand extends ZapierBaseCommand {
14
9
  async perform() {
15
10
  this.startSpinner('Loading team members');
16
- const { admins, subscribers } = await listEndpointMulti(
17
- { endpoint: 'collaborators', keyOverride: 'admins' },
18
- {
19
- endpoint: (app) =>
20
- `${BASE_ENDPOINT}/api/platform/v3/integrations/${app.id}/subscribers`,
21
- keyOverride: 'subscribers',
22
- }
23
- );
11
+ const { admins, limitedCollaborators, subscribers } =
12
+ await listTeamMembers();
24
13
 
25
- const choices = [...admins, ...subscribers].map(
14
+ const choices = [...admins, ...limitedCollaborators, ...subscribers].map(
26
15
  ({ status, name, role, email, id }) => ({
27
16
  status,
28
- value: { id, email, role: roleName(role) },
29
- name: `${email} (${roleName(role)})`,
17
+ value: { id, email, role: transformUserRole(role) },
18
+ name: `${email} (${transformUserRole(role)})`,
30
19
  short: email,
31
20
  })
32
21
  );
33
22
 
34
23
  this.stopSpinner();
35
24
 
36
- const { role, email, id: invitationId } = await this.promptWithList(
25
+ const {
26
+ role,
27
+ email,
28
+ id: invitationId,
29
+ } = await this.promptWithList(
37
30
  'Which team member do you want to remove?',
38
31
  choices
39
32
  );
@@ -50,18 +43,19 @@ class TeamRemoveCommand extends ZapierBaseCommand {
50
43
  return;
51
44
  }
52
45
 
53
- const roleIsAdmin = role === 'admin';
54
-
55
46
  this.startSpinner('Removing Team Member');
56
47
  const { id: appId } = await getWritableApp();
57
- const url = roleIsAdmin
58
- ? `/apps/${appId}/collaborators/${invitationId}`
59
- : `${BASE_ENDPOINT}/api/platform/v3/integrations/${appId}/subscribers/${invitationId}`;
48
+ const url =
49
+ role === 'admin'
50
+ ? `/apps/${appId}/collaborators/${invitationId}`
51
+ : role === 'subscriber'
52
+ ? `${BASE_ENDPOINT}/api/platform/v3/integrations/${appId}/subscribers/${invitationId}`
53
+ : `/apps/${appId}/limited_collaborators`;
60
54
 
61
55
  await callAPI(url, {
62
56
  url: url.startsWith('http') ? url : undefined,
63
57
  method: 'DELETE',
64
- body: { email: this.args.email },
58
+ body: { email_id: invitationId },
65
59
  });
66
60
 
67
61
  this.stopSpinner();
@@ -71,7 +65,10 @@ class TeamRemoveCommand extends ZapierBaseCommand {
71
65
  TeamRemoveCommand.flags = buildFlags();
72
66
  TeamRemoveCommand.description = `Remove a team member from all versions of your integration.
73
67
 
74
- Admins will immediately lose write access to the integration. Subscribers won't receive future email updates.`;
68
+ Admins will immediately lose write access to the integration.
69
+ Collaborators will immediately lose read access to the integration.
70
+ Subscribers won't receive future email updates.`;
71
+
75
72
  TeamRemoveCommand.aliases = ['team:delete'];
76
73
 
77
74
  module.exports = TeamRemoveCommand;
@@ -29,7 +29,12 @@ const {
29
29
  removeDir,
30
30
  } = require('./files');
31
31
 
32
- const { prettyJSONstringify, startSpinner, endSpinner } = require('./display');
32
+ const {
33
+ prettyJSONstringify,
34
+ startSpinner,
35
+ endSpinner,
36
+ flattenCheckResult,
37
+ } = require('./display');
33
38
 
34
39
  const {
35
40
  getLinkedAppConfig,
@@ -434,6 +439,17 @@ const _buildFunc = async ({
434
439
  );
435
440
  }
436
441
  endSpinner();
442
+
443
+ if (_.get(styleChecksResponse, ['warnings', 'total_failures'])) {
444
+ console.log(colors.yellow('WARNINGS:'));
445
+ const checkIssues = flattenCheckResult(styleChecksResponse);
446
+ for (const issue of checkIssues) {
447
+ if (issue.category !== 'Errors') {
448
+ console.log(colors.yellow(`- ${issue.description}`));
449
+ }
450
+ }
451
+ console.log(colors.yellow('Run `zapier validate` for more details.'));
452
+ }
437
453
  } else {
438
454
  debug('\nWarning: Skipping Validation');
439
455
  }
@@ -0,0 +1,33 @@
1
+ const { listEndpointMulti } = require('./api');
2
+ const constants = require('../constants');
3
+
4
+ /**
5
+ * BE: 'collaborator' = FE: 'admin'
6
+ * BE: 'subscriber' = FE: 'subscriber'
7
+ * BE: 'limited_collaborator' = FE: 'collaborator'
8
+ */
9
+ const transformUserRole = (role) =>
10
+ role === 'collaborator'
11
+ ? 'admin'
12
+ : role === 'subscriber'
13
+ ? 'subscriber'
14
+ : 'collaborator';
15
+
16
+ const listTeamMembers = async () => {
17
+ return listEndpointMulti(
18
+ { endpoint: 'collaborators', keyOverride: 'admins' },
19
+ {
20
+ endpoint: 'limited_collaborators',
21
+ keyOverride: 'limitedCollaborators',
22
+ },
23
+ {
24
+ endpoint: (app) =>
25
+ `${constants.BASE_ENDPOINT}/api/platform/v3/integrations/${app.id}/subscribers`,
26
+ keyOverride: 'subscribers',
27
+ }
28
+ );
29
+ };
30
+ module.exports = {
31
+ listTeamMembers,
32
+ transformUserRole,
33
+ };