@backstage/plugin-notifications-node 0.1.0-next.2 → 0.1.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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # @backstage/plugin-notifications-node
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/catalog-client@1.6.2
9
+ - @backstage/backend-common@0.21.5
10
+ - @backstage/plugin-signals-node@0.1.1
11
+ - @backstage/backend-plugin-api@0.6.15
12
+ - @backstage/catalog-model@1.4.5
13
+ - @backstage/plugin-notifications-common@0.0.2
14
+
15
+ ## 0.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 84af361: Migrated to using the new auth services.
20
+
21
+ ### Patch Changes
22
+
23
+ - ba14c0e: Support for broadcast notifications
24
+ - a790a3d: Move notification origin resolving to backend with new auth
25
+ - 0fb419b: Updated dependency `uuid` to `^9.0.0`.
26
+ Updated dependency `@types/uuid` to `^9.0.0`.
27
+ - Updated dependencies
28
+ - @backstage/plugin-notifications-common@0.0.2
29
+ - @backstage/backend-common@0.21.4
30
+ - @backstage/plugin-signals-node@0.1.0
31
+ - @backstage/backend-plugin-api@0.6.14
32
+ - @backstage/catalog-client@1.6.1
33
+ - @backstage/catalog-model@1.4.5
34
+
3
35
  ## 0.1.0-next.2
4
36
 
5
37
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
4
 
7
5
  class DefaultNotificationService {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/service/DefaultNotificationService.ts","../src/lib.ts","../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\n\nimport { NotificationService } from './NotificationService';\nimport { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';\nimport { NotificationPayload } from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport type NotificationServiceOptions = {\n auth: AuthService;\n discovery: DiscoveryService;\n};\n\n/** @public */\nexport type NotificationRecipients = {\n type: 'entity';\n entityRef: string | string[];\n};\n\n// TODO: Support for broadcast messages\n// | { type: 'broadcast' };\n\n/** @public */\nexport type NotificationSendOptions = {\n recipients: NotificationRecipients;\n payload: NotificationPayload;\n};\n\n/** @public */\nexport class DefaultNotificationService implements NotificationService {\n private constructor(\n private readonly discovery: DiscoveryService,\n private readonly auth: AuthService,\n ) {}\n\n static create(\n options: NotificationServiceOptions,\n ): DefaultNotificationService {\n return new DefaultNotificationService(options.discovery, options.auth);\n }\n\n async send(notification: NotificationSendOptions): Promise<void> {\n try {\n const baseUrl = await this.discovery.getBaseUrl('notifications');\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'notifications',\n });\n\n const response = await fetch(`${baseUrl}/`, {\n method: 'POST',\n body: JSON.stringify(notification),\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n } catch (error) {\n // TODO: Should not throw in optimal case, see BEP\n throw new Error(`Failed to send notifications: ${error}`);\n }\n }\n}\n","/*\n * Copyright 2023 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 {\n coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { DefaultNotificationService } from './service';\nimport { NotificationService } from './service/NotificationService';\n\n/** @public */\nexport const notificationService = createServiceRef<NotificationService>({\n id: 'notifications.service',\n scope: 'plugin',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discovery: coreServices.discovery,\n },\n factory({ auth, discovery }) {\n return DefaultNotificationService.create({\n auth,\n discovery,\n });\n },\n }),\n});\n","/*\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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { Notification } from '@backstage/plugin-notifications-common';\n\n/**\n * @public\n */\nexport interface NotificationProcessor {\n /**\n * Decorate notification before sending it\n *\n * @param notification - The notification to decorate\n * @returns The same notification or a modified version of it\n */\n decorate?(notification: Notification): Promise<Notification>;\n\n /**\n * Send notification using this processor.\n *\n * @param notification - The notification to send\n */\n send?(notification: Notification): Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface NotificationsProcessingExtensionPoint {\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void;\n}\n\n/**\n * @public\n */\nexport const notificationsProcessingExtensionPoint =\n createExtensionPoint<NotificationsProcessingExtensionPoint>({\n id: 'not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AAAA,aACO,KAAO,EAAA;AAEd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AAAA,KAC1D;AAAA,GACF;AACF;;ACxDO,MAAM,sBAAsBA,iCAAsC,CAAA;AAAA,EACvE,EAAI,EAAA,uBAAA;AAAA,EACJ,KAAO,EAAA,QAAA;AAAA,EACP,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAqB,CAAA;AAAA,IACnB,OAAA;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,MAAMC,6BAAa,CAAA,IAAA;AAAA,MACnB,WAAWA,6BAAa,CAAA,SAAA;AAAA,KAC1B;AAAA,IACA,OAAQ,CAAA,EAAE,IAAM,EAAA,SAAA,EAAa,EAAA;AAC3B,MAAA,OAAO,2BAA2B,MAAO,CAAA;AAAA,QACvC,IAAA;AAAA,QACA,SAAA;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACD,CAAA;AACL,CAAC;;ACSM,MAAM,wCACXC,qCAA4D,CAAA;AAAA,EAC1D,EAAI,EAAA,0BAAA;AACN,CAAC;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/service/DefaultNotificationService.ts","../src/lib.ts","../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\n\nimport { NotificationService } from './NotificationService';\nimport { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';\nimport { NotificationPayload } from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport type NotificationServiceOptions = {\n auth: AuthService;\n discovery: DiscoveryService;\n};\n\n/** @public */\nexport type NotificationRecipients =\n | {\n type: 'entity';\n entityRef: string | string[];\n }\n | { type: 'broadcast' };\n\n/** @public */\nexport type NotificationSendOptions = {\n recipients: NotificationRecipients;\n payload: NotificationPayload;\n};\n\n/** @public */\nexport class DefaultNotificationService implements NotificationService {\n private constructor(\n private readonly discovery: DiscoveryService,\n private readonly auth: AuthService,\n ) {}\n\n static create(\n options: NotificationServiceOptions,\n ): DefaultNotificationService {\n return new DefaultNotificationService(options.discovery, options.auth);\n }\n\n async send(notification: NotificationSendOptions): Promise<void> {\n try {\n const baseUrl = await this.discovery.getBaseUrl('notifications');\n const { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'notifications',\n });\n\n const response = await fetch(`${baseUrl}/`, {\n method: 'POST',\n body: JSON.stringify(notification),\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n } catch (error) {\n // TODO: Should not throw in optimal case, see BEP\n throw new Error(`Failed to send notifications: ${error}`);\n }\n }\n}\n","/*\n * Copyright 2023 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 {\n coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { DefaultNotificationService } from './service';\nimport { NotificationService } from './service/NotificationService';\n\n/** @public */\nexport const notificationService = createServiceRef<NotificationService>({\n id: 'notifications.service',\n scope: 'plugin',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discovery: coreServices.discovery,\n },\n factory({ auth, discovery }) {\n return DefaultNotificationService.create({\n auth,\n discovery,\n });\n },\n }),\n});\n","/*\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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { Notification } from '@backstage/plugin-notifications-common';\n\n/**\n * @public\n */\nexport interface NotificationProcessor {\n /**\n * Decorate notification before sending it\n *\n * @param notification - The notification to decorate\n * @returns The same notification or a modified version of it\n */\n decorate?(notification: Notification): Promise<Notification>;\n\n /**\n * Send notification using this processor.\n *\n * @param notification - The notification to send\n */\n send?(notification: Notification): Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface NotificationsProcessingExtensionPoint {\n addProcessor(\n ...processors: Array<NotificationProcessor | Array<NotificationProcessor>>\n ): void;\n}\n\n/**\n * @public\n */\nexport const notificationsProcessingExtensionPoint =\n createExtensionPoint<NotificationsProcessingExtensionPoint>({\n id: 'notifications.processing',\n });\n"],"names":["createServiceRef","createServiceFactory","coreServices","createExtensionPoint"],"mappings":";;;;AAyCO,MAAM,0BAA0D,CAAA;AAAA,EAC7D,WAAA,CACW,WACA,IACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA,CAAA;AAAA,GAChB;AAAA,EAEH,OAAO,OACL,OAC4B,EAAA;AAC5B,IAAA,OAAO,IAAI,0BAAA,CAA2B,OAAQ,CAAA,SAAA,EAAW,QAAQ,IAAI,CAAA,CAAA;AAAA,G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,MACnB,WAAWA,6BAAa,CAAA,SAAA;AAAA,KAC1B;AAAA,IACA,OAAQ,CAAA,EAAE,IAAM,EAAA,SAAA,EAAa,EAAA;AAC3B,MAAA,OAAO,2BAA2B,MAAO,CAAA;AAAA,QACvC,IAAA;AAAA,QACA,SAAA;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACD,CAAA;AACL,CAAC;;ACSM,MAAM,wCACXC,qCAA4D,CAAA;AAAA,EAC1D,EAAI,EAAA,0BAAA;AACN,CAAC;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ type NotificationServiceOptions = {
16
16
  type NotificationRecipients = {
17
17
  type: 'entity';
18
18
  entityRef: string | string[];
19
+ } | {
20
+ type: 'broadcast';
19
21
  };
20
22
  /** @public */
21
23
  type NotificationSendOptions = {
@@ -63,4 +65,4 @@ interface NotificationsProcessingExtensionPoint {
63
65
  */
64
66
  declare const notificationsProcessingExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<NotificationsProcessingExtensionPoint>;
65
67
 
66
- export { DefaultNotificationService, NotificationProcessor, NotificationRecipients, NotificationSendOptions, NotificationService, NotificationServiceOptions, NotificationsProcessingExtensionPoint, notificationService, notificationsProcessingExtensionPoint };
68
+ export { DefaultNotificationService, type NotificationProcessor, type NotificationRecipients, type NotificationSendOptions, type NotificationService, type NotificationServiceOptions, type NotificationsProcessingExtensionPoint, notificationService, notificationsProcessingExtensionPoint };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications-node",
3
3
  "description": "Node.js library for the notifications plugin",
4
- "version": "0.1.0-next.2",
4
+ "version": "0.1.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -27,21 +27,21 @@
27
27
  "postpack": "backstage-cli package postpack"
28
28
  },
29
29
  "devDependencies": {
30
- "@backstage/backend-test-utils": "^0.3.4-next.2",
31
- "@backstage/cli": "^0.25.3-next.2",
32
- "@backstage/test-utils": "^1.5.1-next.1",
30
+ "@backstage/backend-test-utils": "^0.3.5",
31
+ "@backstage/cli": "^0.26.1",
32
+ "@backstage/test-utils": "^1.5.2",
33
33
  "msw": "^1.0.0"
34
34
  },
35
35
  "files": [
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@backstage/backend-common": "^0.21.4-next.2",
40
- "@backstage/backend-plugin-api": "^0.6.14-next.2",
41
- "@backstage/catalog-client": "^1.6.1-next.1",
42
- "@backstage/catalog-model": "^1.4.5-next.0",
43
- "@backstage/plugin-notifications-common": "^0.0.2-next.1",
44
- "@backstage/plugin-signals-node": "^0.1.0-next.2",
39
+ "@backstage/backend-common": "^0.21.5",
40
+ "@backstage/backend-plugin-api": "^0.6.15",
41
+ "@backstage/catalog-client": "^1.6.2",
42
+ "@backstage/catalog-model": "^1.4.5",
43
+ "@backstage/plugin-notifications-common": "^0.0.2",
44
+ "@backstage/plugin-signals-node": "^0.1.1",
45
45
  "knex": "^3.0.0",
46
46
  "uuid": "^9.0.0"
47
47
  }