@backstage/plugin-notifications-common 0.0.5 → 0.0.6-next.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/CHANGELOG.md +8 -0
- package/dist/constants.cjs.js +11 -0
- package/dist/constants.cjs.js.map +1 -0
- package/dist/filters.cjs.js +34 -0
- package/dist/filters.cjs.js.map +1 -0
- package/dist/index.cjs.js +7 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/utils.cjs.js +16 -0
- package/dist/utils.cjs.js.map +1 -0
- package/dist/utils.esm.js +14 -0
- package/dist/utils.esm.js.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs.js","sources":["../src/constants.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { NotificationSeverity } from './types';\n\n/** Ordered list of severities used by the Notifications.\n *\n * @public */\nexport const notificationSeverities: NotificationSeverity[] = [\n 'critical',\n 'high',\n 'normal',\n 'low',\n];\n"],"names":[],"mappings":";;AAoBO,MAAM,sBAAiD,GAAA;AAAA,EAC5D,UAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.cjs.js');
|
|
4
|
+
|
|
5
|
+
const getProcessorFiltersFromConfig = (config) => {
|
|
6
|
+
const filter = {};
|
|
7
|
+
const minSeverity = config.getOptionalString(
|
|
8
|
+
"filter.minSeverity"
|
|
9
|
+
);
|
|
10
|
+
if (minSeverity) {
|
|
11
|
+
if (constants.notificationSeverities.includes(minSeverity)) {
|
|
12
|
+
filter.minSeverity = minSeverity;
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error(`Invalid minSeverity: ${minSeverity}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const maxSeverity = config.getOptionalString(
|
|
18
|
+
"filter.maxSeverity"
|
|
19
|
+
);
|
|
20
|
+
if (maxSeverity) {
|
|
21
|
+
if (constants.notificationSeverities.includes(maxSeverity)) {
|
|
22
|
+
filter.maxSeverity = maxSeverity;
|
|
23
|
+
} else {
|
|
24
|
+
throw new Error(`Invalid maxSeverity: ${maxSeverity}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
filter.excludedTopics = config.getOptionalStringArray(
|
|
28
|
+
"filter.excludedTopics"
|
|
29
|
+
);
|
|
30
|
+
return filter;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getProcessorFiltersFromConfig = getProcessorFiltersFromConfig;
|
|
34
|
+
//# sourceMappingURL=filters.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.cjs.js","sources":["../src/filters.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Config } from '@backstage/config';\nimport { NotificationProcessorFilters, NotificationSeverity } from './types';\nimport { notificationSeverities } from './constants';\n\n/** @public */\nexport const getProcessorFiltersFromConfig = (config: Config) => {\n const filter: NotificationProcessorFilters = {};\n const minSeverity = config.getOptionalString(\n 'filter.minSeverity',\n ) as NotificationSeverity;\n if (minSeverity) {\n if (notificationSeverities.includes(minSeverity)) {\n filter.minSeverity = minSeverity;\n } else {\n throw new Error(`Invalid minSeverity: ${minSeverity}`);\n }\n }\n const maxSeverity = config.getOptionalString(\n 'filter.maxSeverity',\n ) as NotificationSeverity;\n if (maxSeverity) {\n if (notificationSeverities.includes(maxSeverity)) {\n filter.maxSeverity = maxSeverity;\n } else {\n throw new Error(`Invalid maxSeverity: ${maxSeverity}`);\n }\n }\n filter.excludedTopics = config.getOptionalStringArray(\n 'filter.excludedTopics',\n );\n return filter;\n};\n"],"names":["notificationSeverities"],"mappings":";;;;AAoBa,MAAA,6BAAA,GAAgC,CAAC,MAAmB,KAAA;AAC/D,EAAA,MAAM,SAAuC,EAAC,CAAA;AAC9C,EAAA,MAAM,cAAc,MAAO,CAAA,iBAAA;AAAA,IACzB,oBAAA;AAAA,GACF,CAAA;AACA,EAAA,IAAI,WAAa,EAAA;AACf,IAAI,IAAAA,gCAAA,CAAuB,QAAS,CAAA,WAAW,CAAG,EAAA;AAChD,MAAA,MAAA,CAAO,WAAc,GAAA,WAAA,CAAA;AAAA,KAChB,MAAA;AACL,MAAA,MAAM,IAAI,KAAA,CAAM,CAAwB,qBAAA,EAAA,WAAW,CAAE,CAAA,CAAA,CAAA;AAAA,KACvD;AAAA,GACF;AACA,EAAA,MAAM,cAAc,MAAO,CAAA,iBAAA;AAAA,IACzB,oBAAA;AAAA,GACF,CAAA;AACA,EAAA,IAAI,WAAa,EAAA;AACf,IAAI,IAAAA,gCAAA,CAAuB,QAAS,CAAA,WAAW,CAAG,EAAA;AAChD,MAAA,MAAA,CAAO,WAAc,GAAA,WAAA,CAAA;AAAA,KAChB,MAAA;AACL,MAAA,MAAM,IAAI,KAAA,CAAM,CAAwB,qBAAA,EAAA,WAAW,CAAE,CAAA,CAAA,CAAA;AAAA,KACvD;AAAA,GACF;AACA,EAAA,MAAA,CAAO,iBAAiB,MAAO,CAAA,sBAAA;AAAA,IAC7B,uBAAA;AAAA,GACF,CAAA;AACA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"normal",
|
|
7
|
-
"low"
|
|
8
|
-
];
|
|
3
|
+
var constants = require('./constants.cjs.js');
|
|
4
|
+
var filters = require('./filters.cjs.js');
|
|
5
|
+
var utils = require('./utils.cjs.js');
|
|
9
6
|
|
|
10
|
-
const getProcessorFiltersFromConfig = (config) => {
|
|
11
|
-
const filter = {};
|
|
12
|
-
const minSeverity = config.getOptionalString(
|
|
13
|
-
"filter.minSeverity"
|
|
14
|
-
);
|
|
15
|
-
if (minSeverity) {
|
|
16
|
-
if (notificationSeverities.includes(minSeverity)) {
|
|
17
|
-
filter.minSeverity = minSeverity;
|
|
18
|
-
} else {
|
|
19
|
-
throw new Error(`Invalid minSeverity: ${minSeverity}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const maxSeverity = config.getOptionalString(
|
|
23
|
-
"filter.maxSeverity"
|
|
24
|
-
);
|
|
25
|
-
if (maxSeverity) {
|
|
26
|
-
if (notificationSeverities.includes(maxSeverity)) {
|
|
27
|
-
filter.maxSeverity = maxSeverity;
|
|
28
|
-
} else {
|
|
29
|
-
throw new Error(`Invalid maxSeverity: ${maxSeverity}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
filter.excludedTopics = config.getOptionalStringArray(
|
|
33
|
-
"filter.excludedTopics"
|
|
34
|
-
);
|
|
35
|
-
return filter;
|
|
36
|
-
};
|
|
37
7
|
|
|
38
|
-
|
|
39
|
-
exports.notificationSeverities = notificationSeverities;
|
|
8
|
+
|
|
9
|
+
exports.notificationSeverities = constants.notificationSeverities;
|
|
10
|
+
exports.getProcessorFiltersFromConfig = filters.getProcessorFiltersFromConfig;
|
|
11
|
+
exports.isNotificationsEnabledFor = utils.isNotificationsEnabledFor;
|
|
40
12
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,18 @@ type NotificationProcessorFilters = {
|
|
|
102
102
|
maxSeverity?: NotificationSeverity;
|
|
103
103
|
excludedTopics?: string[];
|
|
104
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
type NotificationSettings = {
|
|
109
|
+
channels: {
|
|
110
|
+
id: string;
|
|
111
|
+
origins: {
|
|
112
|
+
id: string;
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
}[];
|
|
115
|
+
}[];
|
|
116
|
+
};
|
|
105
117
|
|
|
106
118
|
/** Ordered list of severities used by the Notifications.
|
|
107
119
|
*
|
|
@@ -111,4 +123,7 @@ declare const notificationSeverities: NotificationSeverity[];
|
|
|
111
123
|
/** @public */
|
|
112
124
|
declare const getProcessorFiltersFromConfig: (config: Config) => NotificationProcessorFilters;
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
/** @public */
|
|
127
|
+
declare const isNotificationsEnabledFor: (settings: NotificationSettings, channelId: string, originId: string) => boolean;
|
|
128
|
+
|
|
129
|
+
export { type NewNotificationSignal, type Notification, type NotificationPayload, type NotificationProcessorFilters, type NotificationReadSignal, type NotificationSettings, type NotificationSeverity, type NotificationSignal, type NotificationStatus, getProcessorFiltersFromConfig, isNotificationsEnabledFor, notificationSeverities };
|
package/dist/index.esm.js
CHANGED
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isNotificationsEnabledFor = (settings, channelId, originId) => {
|
|
4
|
+
const channel = settings.channels.find((c) => c.id === channelId);
|
|
5
|
+
if (!channel) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const origin = channel.origins.find((o) => o.id === originId);
|
|
9
|
+
if (!origin) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return origin.enabled;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.isNotificationsEnabledFor = isNotificationsEnabledFor;
|
|
16
|
+
//# sourceMappingURL=utils.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs.js","sources":["../src/utils.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { NotificationSettings } from './types';\n\n/** @public */\nexport const isNotificationsEnabledFor = (\n settings: NotificationSettings,\n channelId: string,\n originId: string,\n) => {\n const channel = settings.channels.find(c => c.id === channelId);\n if (!channel) {\n return true;\n }\n\n const origin = channel.origins.find(o => o.id === originId);\n if (!origin) {\n return true;\n }\n return origin.enabled;\n};\n"],"names":[],"mappings":";;AAkBO,MAAM,yBAA4B,GAAA,CACvC,QACA,EAAA,SAAA,EACA,QACG,KAAA;AACH,EAAA,MAAM,UAAU,QAAS,CAAA,QAAA,CAAS,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,SAAS,CAAA,CAAA;AAC9D,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,SAAS,OAAQ,CAAA,OAAA,CAAQ,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,QAAQ,CAAA,CAAA;AAC1D,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAA,OAAO,MAAO,CAAA,OAAA,CAAA;AAChB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const isNotificationsEnabledFor = (settings, channelId, originId) => {
|
|
2
|
+
const channel = settings.channels.find((c) => c.id === channelId);
|
|
3
|
+
if (!channel) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
const origin = channel.origins.find((o) => o.id === originId);
|
|
7
|
+
if (!origin) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return origin.enabled;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { isNotificationsEnabledFor };
|
|
14
|
+
//# sourceMappingURL=utils.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.esm.js","sources":["../src/utils.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { NotificationSettings } from './types';\n\n/** @public */\nexport const isNotificationsEnabledFor = (\n settings: NotificationSettings,\n channelId: string,\n originId: string,\n) => {\n const channel = settings.channels.find(c => c.id === channelId);\n if (!channel) {\n return true;\n }\n\n const origin = channel.origins.find(o => o.id === originId);\n if (!origin) {\n return true;\n }\n return origin.enabled;\n};\n"],"names":[],"mappings":"AAkBO,MAAM,yBAA4B,GAAA,CACvC,QACA,EAAA,SAAA,EACA,QACG,KAAA;AACH,EAAA,MAAM,UAAU,QAAS,CAAA,QAAA,CAAS,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,SAAS,CAAA,CAAA;AAC9D,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,SAAS,OAAQ,CAAA,OAAA,CAAQ,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,QAAQ,CAAA,CAAA;AAC1D,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAA,OAAO,MAAO,CAAA,OAAA,CAAA;AAChB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-next.0",
|
|
4
4
|
"description": "Common functionalities for the notifications plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "common-library",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"test": "backstage-cli package test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@backstage/config": "
|
|
42
|
+
"@backstage/config": "1.2.0",
|
|
43
43
|
"@material-ui/icons": "^4.9.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/cli": "
|
|
46
|
+
"@backstage/cli": "0.29.0-next.0"
|
|
47
47
|
},
|
|
48
48
|
"module": "dist/index.esm.js"
|
|
49
49
|
}
|