@backstage/plugin-notifications-common 0.0.4 → 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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/plugin-notifications-common
2
2
 
3
+ ## 0.0.6-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 97ba58f: Add support for user specific notification settings
8
+ - Updated dependencies
9
+ - @backstage/config@1.2.0
10
+
11
+ ## 0.0.5
12
+
13
+ ### Patch Changes
14
+
15
+ - 4e4ef2b: Move notification processor filter parsing to common package
16
+ - Updated dependencies
17
+ - @backstage/config@1.2.0
18
+
3
19
  ## 0.0.4
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const notificationSeverities = [
4
+ "critical",
5
+ "high",
6
+ "normal",
7
+ "low"
8
+ ];
9
+
10
+ exports.notificationSeverities = notificationSeverities;
11
+ //# sourceMappingURL=constants.cjs.js.map
@@ -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;;;;"}
@@ -0,0 +1,32 @@
1
+ import { notificationSeverities } from './constants.esm.js';
2
+
3
+ const getProcessorFiltersFromConfig = (config) => {
4
+ const filter = {};
5
+ const minSeverity = config.getOptionalString(
6
+ "filter.minSeverity"
7
+ );
8
+ if (minSeverity) {
9
+ if (notificationSeverities.includes(minSeverity)) {
10
+ filter.minSeverity = minSeverity;
11
+ } else {
12
+ throw new Error(`Invalid minSeverity: ${minSeverity}`);
13
+ }
14
+ }
15
+ const maxSeverity = config.getOptionalString(
16
+ "filter.maxSeverity"
17
+ );
18
+ if (maxSeverity) {
19
+ if (notificationSeverities.includes(maxSeverity)) {
20
+ filter.maxSeverity = maxSeverity;
21
+ } else {
22
+ throw new Error(`Invalid maxSeverity: ${maxSeverity}`);
23
+ }
24
+ }
25
+ filter.excludedTopics = config.getOptionalStringArray(
26
+ "filter.excludedTopics"
27
+ );
28
+ return filter;
29
+ };
30
+
31
+ export { getProcessorFiltersFromConfig };
32
+ //# sourceMappingURL=filters.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.esm.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":[],"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,IAAA,sBAAA,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,IAAA,sBAAA,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,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const notificationSeverities = [
4
- "critical",
5
- "high",
6
- "normal",
7
- "low"
8
- ];
9
-
10
- exports.notificationSeverities = notificationSeverities;
3
+ var constants = require('./constants.cjs.js');
4
+ var filters = require('./filters.cjs.js');
5
+ var utils = require('./utils.cjs.js');
6
+
7
+
8
+
9
+ exports.notificationSeverities = constants.notificationSeverities;
10
+ exports.getProcessorFiltersFromConfig = filters.getProcessorFiltersFromConfig;
11
+ exports.isNotificationsEnabledFor = utils.isNotificationsEnabledFor;
11
12
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.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;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Config } from '@backstage/config';
2
+
1
3
  /** @public */
2
4
  type NotificationSeverity = 'critical' | 'high' | 'normal' | 'low';
3
5
  /** @public */
@@ -92,10 +94,36 @@ type NotificationReadSignal = {
92
94
  };
93
95
  /** @public */
94
96
  type NotificationSignal = NewNotificationSignal | NotificationReadSignal;
97
+ /**
98
+ * @public
99
+ */
100
+ type NotificationProcessorFilters = {
101
+ minSeverity?: NotificationSeverity;
102
+ maxSeverity?: NotificationSeverity;
103
+ excludedTopics?: string[];
104
+ };
105
+ /**
106
+ * @public
107
+ */
108
+ type NotificationSettings = {
109
+ channels: {
110
+ id: string;
111
+ origins: {
112
+ id: string;
113
+ enabled: boolean;
114
+ }[];
115
+ }[];
116
+ };
95
117
 
96
118
  /** Ordered list of severities used by the Notifications.
97
119
  *
98
120
  * @public */
99
121
  declare const notificationSeverities: NotificationSeverity[];
100
122
 
101
- export { type NewNotificationSignal, type Notification, type NotificationPayload, type NotificationReadSignal, type NotificationSeverity, type NotificationSignal, type NotificationStatus, notificationSeverities };
123
+ /** @public */
124
+ declare const getProcessorFiltersFromConfig: (config: Config) => NotificationProcessorFilters;
125
+
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
@@ -1,2 +1,4 @@
1
1
  export { notificationSeverities } from './constants.esm.js';
2
+ export { getProcessorFiltersFromConfig } from './filters.esm.js';
3
+ export { isNotificationsEnabledFor } from './utils.esm.js';
2
4
  //# sourceMappingURL=index.esm.js.map
@@ -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.4",
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,10 +39,11 @@
39
39
  "test": "backstage-cli package test"
40
40
  },
41
41
  "dependencies": {
42
+ "@backstage/config": "1.2.0",
42
43
  "@material-ui/icons": "^4.9.1"
43
44
  },
44
45
  "devDependencies": {
45
- "@backstage/cli": "^0.26.7"
46
+ "@backstage/cli": "0.29.0-next.0"
46
47
  },
47
48
  "module": "dist/index.esm.js"
48
49
  }