@backstage/plugin-notifications-common 0.1.2-next.0 → 0.2.0-next.1
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 +9 -0
- package/dist/index.d.ts +30 -0
- package/dist/utils.cjs.js +7 -7
- package/dist/utils.cjs.js.map +1 -1
- package/dist/utils.esm.js +7 -7
- package/dist/utils.esm.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-common
|
|
2
2
|
|
|
3
|
+
## 0.2.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 87e597c: Adds support for default configuration for an entire notification channel.
|
|
8
|
+
This setting will also be inherited down to origins and topics while still respecting the users individual choices.
|
|
9
|
+
|
|
10
|
+
This will be handy if you want to use a "opt-in" strategy.
|
|
11
|
+
|
|
3
12
|
## 0.1.2-next.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -113,28 +113,58 @@ type NotificationProcessorFilters = {
|
|
|
113
113
|
* @public
|
|
114
114
|
*/
|
|
115
115
|
type TopicSetting = {
|
|
116
|
+
/**
|
|
117
|
+
* Topic identifier
|
|
118
|
+
*/
|
|
116
119
|
id: string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether notifications for this topic are enabled
|
|
122
|
+
*/
|
|
117
123
|
enabled: boolean;
|
|
118
124
|
};
|
|
119
125
|
/**
|
|
120
126
|
* @public
|
|
121
127
|
*/
|
|
122
128
|
type OriginSetting = {
|
|
129
|
+
/**
|
|
130
|
+
* Origin identifier
|
|
131
|
+
*/
|
|
123
132
|
id: string;
|
|
133
|
+
/**
|
|
134
|
+
* Whether notifications from this origin are enabled
|
|
135
|
+
*/
|
|
124
136
|
enabled: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Optional array of topic-specific settings
|
|
139
|
+
*/
|
|
125
140
|
topics?: TopicSetting[];
|
|
126
141
|
};
|
|
127
142
|
/**
|
|
128
143
|
* @public
|
|
129
144
|
*/
|
|
130
145
|
type ChannelSetting = {
|
|
146
|
+
/**
|
|
147
|
+
* Channel identifier
|
|
148
|
+
*/
|
|
131
149
|
id: string;
|
|
150
|
+
/**
|
|
151
|
+
* Optional flag to enable/disable the channel by default.
|
|
152
|
+
* If not set, defaults to true for backwards compatibility.
|
|
153
|
+
* When set to false, the channel uses an opt-in strategy.
|
|
154
|
+
*/
|
|
155
|
+
enabled?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Array of origin settings for this channel
|
|
158
|
+
*/
|
|
132
159
|
origins: OriginSetting[];
|
|
133
160
|
};
|
|
134
161
|
/**
|
|
135
162
|
* @public
|
|
136
163
|
*/
|
|
137
164
|
type NotificationSettings = {
|
|
165
|
+
/**
|
|
166
|
+
* Array of channel settings
|
|
167
|
+
*/
|
|
138
168
|
channels: ChannelSetting[];
|
|
139
169
|
};
|
|
140
170
|
|
package/dist/utils.cjs.js
CHANGED
|
@@ -7,16 +7,16 @@ const isNotificationsEnabledFor = (settings, channelId, originId, topicId) => {
|
|
|
7
7
|
}
|
|
8
8
|
const origin = channel.origins.find((o) => o.id === originId);
|
|
9
9
|
if (!origin) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
if (topicId === null) {
|
|
13
|
-
return origin.enabled;
|
|
10
|
+
return channel.enabled ?? true;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (topicId !== null) {
|
|
13
|
+
const topic = origin.topics?.find((t) => t.id === topicId);
|
|
14
|
+
if (topic) {
|
|
15
|
+
return topic.enabled;
|
|
16
|
+
}
|
|
17
17
|
return origin.enabled;
|
|
18
18
|
}
|
|
19
|
-
return
|
|
19
|
+
return origin.enabled;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
exports.isNotificationsEnabledFor = isNotificationsEnabledFor;
|
package/dist/utils.cjs.js.map
CHANGED
|
@@ -1 +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 topicId: string | null,\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 if (topicId
|
|
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 topicId: string | null,\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 // If no origin is found, use channel's enabled flag (defaults to true if not set)\n return channel.enabled ?? true;\n }\n\n // If topic is specified, check topic-level setting\n if (topicId !== null) {\n const topic = origin.topics?.find(t => t.id === topicId);\n if (topic) {\n return topic.enabled;\n }\n // No explicit topic setting, check origin\n return origin.enabled;\n }\n\n // No topic specified, check origin-level setting\n return origin.enabled;\n};\n"],"names":[],"mappings":";;AAkBO,MAAM,yBAAA,GAA4B,CACvC,QAAA,EACA,SAAA,EACA,UACA,OAAA,KACG;AACH,EAAA,MAAM,UAAU,QAAA,CAAS,QAAA,CAAS,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,SAAS,CAAA;AAC9D,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAS,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,QAAQ,CAAA;AAC1D,EAAA,IAAI,CAAC,MAAA,EAAQ;AAEX,IAAA,OAAO,QAAQ,OAAA,IAAW,IAAA;AAAA,EAC5B;AAGA,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,QAAQ,MAAA,CAAO,MAAA,EAAQ,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,OAAO,CAAA;AACvD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,OAAO,KAAA,CAAM,OAAA;AAAA,IACf;AAEA,IAAA,OAAO,MAAA,CAAO,OAAA;AAAA,EAChB;AAGA,EAAA,OAAO,MAAA,CAAO,OAAA;AAChB;;;;"}
|
package/dist/utils.esm.js
CHANGED
|
@@ -5,16 +5,16 @@ const isNotificationsEnabledFor = (settings, channelId, originId, topicId) => {
|
|
|
5
5
|
}
|
|
6
6
|
const origin = channel.origins.find((o) => o.id === originId);
|
|
7
7
|
if (!origin) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
if (topicId === null) {
|
|
11
|
-
return origin.enabled;
|
|
8
|
+
return channel.enabled ?? true;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
if (topicId !== null) {
|
|
11
|
+
const topic = origin.topics?.find((t) => t.id === topicId);
|
|
12
|
+
if (topic) {
|
|
13
|
+
return topic.enabled;
|
|
14
|
+
}
|
|
15
15
|
return origin.enabled;
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return origin.enabled;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { isNotificationsEnabledFor };
|
package/dist/utils.esm.js.map
CHANGED
|
@@ -1 +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 topicId: string | null,\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 if (topicId
|
|
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 topicId: string | null,\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 // If no origin is found, use channel's enabled flag (defaults to true if not set)\n return channel.enabled ?? true;\n }\n\n // If topic is specified, check topic-level setting\n if (topicId !== null) {\n const topic = origin.topics?.find(t => t.id === topicId);\n if (topic) {\n return topic.enabled;\n }\n // No explicit topic setting, check origin\n return origin.enabled;\n }\n\n // No topic specified, check origin-level setting\n return origin.enabled;\n};\n"],"names":[],"mappings":"AAkBO,MAAM,yBAAA,GAA4B,CACvC,QAAA,EACA,SAAA,EACA,UACA,OAAA,KACG;AACH,EAAA,MAAM,UAAU,QAAA,CAAS,QAAA,CAAS,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,SAAS,CAAA;AAC9D,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,SAAS,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,QAAQ,CAAA;AAC1D,EAAA,IAAI,CAAC,MAAA,EAAQ;AAEX,IAAA,OAAO,QAAQ,OAAA,IAAW,IAAA;AAAA,EAC5B;AAGA,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,QAAQ,MAAA,CAAO,MAAA,EAAQ,KAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,OAAO,CAAA;AACvD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,OAAO,KAAA,CAAM,OAAA;AAAA,IACf;AAEA,IAAA,OAAO,MAAA,CAAO,OAAA;AAAA,EAChB;AAGA,EAAA,OAAO,MAAA,CAAO,OAAA;AAChB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-next.1",
|
|
4
4
|
"description": "Common functionalities for the notifications plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "common-library",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@material-ui/icons": "^4.9.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "0.34.5-next.
|
|
47
|
+
"@backstage/cli": "0.34.5-next.1"
|
|
48
48
|
},
|
|
49
49
|
"typesVersions": {
|
|
50
50
|
"*": {
|