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.
- package/README-source.md +2033 -0
- package/README.md +122 -95
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/oclif/commands/migrate.js +44 -10
- package/src/oclif/commands/promote.js +21 -7
- package/src/oclif/commands/team/add.js +26 -13
- package/src/oclif/commands/team/get.js +17 -21
- package/src/oclif/commands/team/remove.js +23 -26
- package/src/utils/build.js +17 -1
- package/src/utils/team.js +33 -0
|
@@ -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 } =
|
|
17
|
-
|
|
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:
|
|
29
|
-
name: `${email} (${
|
|
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 {
|
|
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 =
|
|
58
|
-
|
|
59
|
-
|
|
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: {
|
|
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.
|
|
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;
|
package/src/utils/build.js
CHANGED
|
@@ -29,7 +29,12 @@ const {
|
|
|
29
29
|
removeDir,
|
|
30
30
|
} = require('./files');
|
|
31
31
|
|
|
32
|
-
const {
|
|
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
|
+
};
|