clever-tools 4.5.1 → 4.5.2
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/package.json +1 -1
- package/src/commands/addon/addon.create.command.js +3 -3
- package/src/commands/global.options.js +1 -1
- package/src/commands/notify-email/notify-email.add.command.js +5 -2
- package/src/commands/notify-email/notify-email.command.js +1 -2
- package/src/commands/notify-email/notify-email.docs.md +1 -1
- package/src/commands/webhooks/webhooks.add.command.js +5 -2
- package/src/commands/webhooks/webhooks.command.js +1 -2
- package/src/commands/webhooks/webhooks.docs.md +1 -1
- package/src/models/addon.js +1 -3
- package/src/models/notification.js +7 -6
package/package.json
CHANGED
|
@@ -90,7 +90,7 @@ export const addonCreateCommand = defineCommand({
|
|
|
90
90
|
placeholder: 'region',
|
|
91
91
|
complete: completeRegion,
|
|
92
92
|
}),
|
|
93
|
-
|
|
93
|
+
addonVersion: defineOption({
|
|
94
94
|
name: 'addon-version',
|
|
95
95
|
schema: z.string().optional(),
|
|
96
96
|
description: 'The version to use for the add-on',
|
|
@@ -115,7 +115,7 @@ export const addonCreateCommand = defineCommand({
|
|
|
115
115
|
yes: skipConfirmation,
|
|
116
116
|
org: orgaIdOrName,
|
|
117
117
|
format,
|
|
118
|
-
|
|
118
|
+
addonVersion,
|
|
119
119
|
option: addonOptions,
|
|
120
120
|
} = options;
|
|
121
121
|
|
|
@@ -125,7 +125,7 @@ export const addonCreateCommand = defineCommand({
|
|
|
125
125
|
planName,
|
|
126
126
|
region,
|
|
127
127
|
skipConfirmation,
|
|
128
|
-
version:
|
|
128
|
+
version: addonVersion,
|
|
129
129
|
addonOptions: parseAddonOptions(addonOptions),
|
|
130
130
|
};
|
|
131
131
|
|
|
@@ -148,7 +148,7 @@ export const notificationScopeOption = defineOption({
|
|
|
148
148
|
.string()
|
|
149
149
|
.transform((v) => v.split(','))
|
|
150
150
|
.optional(),
|
|
151
|
-
description: 'Restrict notifications to specific applications and add-ons',
|
|
151
|
+
description: 'Restrict notifications to specific applications and add-ons (requires --org)',
|
|
152
152
|
placeholder: 'service-id',
|
|
153
153
|
});
|
|
154
154
|
|
|
@@ -48,8 +48,11 @@ export const notifyEmailAddCommand = defineCommand({
|
|
|
48
48
|
async handler(options, name) {
|
|
49
49
|
const { org, event: events, service, notify: notifTargets } = options;
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (service != null && org == null) {
|
|
52
|
+
throw new Error('--org is required when using --service');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const { ownerId, appId } = await getOwnerAndApp(org, org == null && service == null);
|
|
53
56
|
|
|
54
57
|
const body = {
|
|
55
58
|
name,
|
|
@@ -18,8 +18,7 @@ export const notifyEmailCommand = defineCommand({
|
|
|
18
18
|
async handler(options) {
|
|
19
19
|
const { org, listAll, format } = options;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
|
|
21
|
+
const { ownerId, appId } = await getOwnerAndApp(org, org == null && !listAll);
|
|
23
22
|
const hooks = await getEmailhooks({ ownerId }).then(sendToApi);
|
|
24
23
|
|
|
25
24
|
const formattedHooks = hooks
|
|
@@ -37,7 +37,7 @@ clever notify-email add --notify <email-address|user-id|organisation> <name> [op
|
|
|
37
37
|
|`--notify` `<email-address\|user-id\|organisation>`|Notify a user, a specific email address or the whole organisation (multiple values allowed, comma separated) **(required)**|
|
|
38
38
|
|`--event` `<event-type>`|Restrict notifications to specific event types|
|
|
39
39
|
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
40
|
-
|`--service` `<service-id>`|Restrict notifications to specific applications and add-ons|
|
|
40
|
+
|`--service` `<service-id>`|Restrict notifications to specific applications and add-ons (requires --org)|
|
|
41
41
|
|
|
42
42
|
## ➡️ `clever notify-email remove` <kbd>Since 0.6.1</kbd>
|
|
43
43
|
|
|
@@ -34,8 +34,11 @@ export const webhooksAddCommand = defineCommand({
|
|
|
34
34
|
async handler(options, name, hookUrl) {
|
|
35
35
|
const { org, format, event: events, service } = options;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (service != null && org == null) {
|
|
38
|
+
throw new Error('--org is required when using --service');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { ownerId, appId } = await getOwnerAndApp(org, org == null && service == null);
|
|
39
42
|
|
|
40
43
|
const body = {
|
|
41
44
|
name,
|
|
@@ -18,8 +18,7 @@ export const webhooksCommand = defineCommand({
|
|
|
18
18
|
async handler(options) {
|
|
19
19
|
const { org, listAll, format } = options;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const { ownerId, appId } = await getOwnerAndApp(null, org, !listAll);
|
|
21
|
+
const { ownerId, appId } = await getOwnerAndApp(org, org == null && !listAll);
|
|
23
22
|
const hooks = await getWebhooks({ ownerId }).then(sendToApi);
|
|
24
23
|
|
|
25
24
|
const formattedHooks = hooks
|
|
@@ -38,7 +38,7 @@ clever webhooks add <name> <url> [options]
|
|
|
38
38
|
|`--event` `<event-type>`|Restrict notifications to specific event types|
|
|
39
39
|
|`--format` `<format>`|Format of the body sent to the webhook ('raw', 'slack', 'gitter', or 'flowdock') (default: raw)|
|
|
40
40
|
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
41
|
-
|`--service` `<service-id>`|Restrict notifications to specific applications and add-ons|
|
|
41
|
+
|`--service` `<service-id>`|Restrict notifications to specific applications and add-ons (requires --org)|
|
|
42
42
|
|
|
43
43
|
## ➡️ `clever webhooks remove` <kbd>Since 0.6.0</kbd>
|
|
44
44
|
|
package/src/models/addon.js
CHANGED
|
@@ -76,9 +76,7 @@ function validateAddonVersionAndOptions(region, version, addonOptions, providerI
|
|
|
76
76
|
const availableVersions = Object.keys(providerInfos.dedicated);
|
|
77
77
|
const hasVersion = availableVersions.find((availableVersion) => availableVersion === version);
|
|
78
78
|
if (hasVersion == null) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Invalid version ${addonOptions.version}, available versions are: ${availableVersions.join(', ')}`,
|
|
81
|
-
);
|
|
79
|
+
throw new Error(`Invalid version ${version}, available versions are: ${availableVersions.join(', ')}`);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
}
|
|
@@ -10,11 +10,12 @@ export function getOrgaIdOrUserId(orgIdOrName) {
|
|
|
10
10
|
return orgIdOrName == null ? User.getCurrentId() : Organisation.getId(orgIdOrName);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export async function getOwnerAndApp(
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
return { ownerId };
|
|
13
|
+
export async function getOwnerAndApp(org, useLinkedApp) {
|
|
14
|
+
if (org != null) {
|
|
15
|
+
return { ownerId: await Organisation.getId(org) };
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (useLinkedApp) {
|
|
18
|
+
return AppConfig.getAppDetails({});
|
|
19
|
+
}
|
|
20
|
+
return { ownerId: await User.getCurrentId() };
|
|
20
21
|
}
|