From a95cebdcb9253528da95f24cfce260fe5988ab45 Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Mon, 15 Sep 2025 20:26:11 -0500 Subject: [PATCH] fix: clean up types Signed-off-by: Paul Schultz --- .changeset/rude-socks-serve.md | 7 +++++++ packages/types/src/observable.ts | 2 +- .../src/lib/SlackNotificationProcessor.ts | 4 +++- .../notifications-backend/migrations/20231215_init.js | 5 +++++ .../migrations/20240221_removeDone.js | 8 ++++++++ .../migrations/20240313_broadcast.js | 7 ++++++- .../migrations/20240808_settings.js | 6 ++++++ .../notifications-backend/migrations/20240902_addIcon.js | 8 ++++++++ .../migrations/20250317_addTopic.js | 9 +++++++++ 9 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .changeset/rude-socks-serve.md diff --git a/.changeset/rude-socks-serve.md b/.changeset/rude-socks-serve.md new file mode 100644 index 0000000000..de75682e8c --- /dev/null +++ b/.changeset/rude-socks-serve.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-notifications-backend-module-slack': patch +'@backstage/plugin-notifications-backend': patch +'@backstage/types': patch +--- + +Internal refactoring for better type support diff --git a/packages/types/src/observable.ts b/packages/types/src/observable.ts index f7292c293c..667875ccd1 100644 --- a/packages/types/src/observable.ts +++ b/packages/types/src/observable.ts @@ -46,7 +46,7 @@ export type Subscription = { // We get the actual runtime polyfill from zen-observable declare global { interface SymbolConstructor { - readonly observable: symbol; + readonly observable: unique symbol; } } diff --git a/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.ts b/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.ts index c587580657..f7dbc6a93e 100644 --- a/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.ts +++ b/plugins/notifications-backend-module-slack/src/lib/SlackNotificationProcessor.ts @@ -42,7 +42,9 @@ export class SlackNotificationProcessor implements NotificationProcessor { private readonly catalog: CatalogService; private readonly auth: AuthService; private readonly slack: WebClient; - private readonly sendNotifications; + private readonly sendNotifications: ( + opts: ChatPostMessageArguments[], + ) => Promise; private readonly messagesSent: Counter; private readonly messagesFailed: Counter; private readonly broadcastChannels?: string[]; diff --git a/plugins/notifications-backend/migrations/20231215_init.js b/plugins/notifications-backend/migrations/20231215_init.js index a1e57237b6..fbe597534c 100644 --- a/plugins/notifications-backend/migrations/20231215_init.js +++ b/plugins/notifications-backend/migrations/20231215_init.js @@ -14,6 +14,11 @@ * limitations under the License. */ +// @ts-check + +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.createTable('notification', table => { table.uuid('id').primary(); diff --git a/plugins/notifications-backend/migrations/20240221_removeDone.js b/plugins/notifications-backend/migrations/20240221_removeDone.js index d67ac81825..2397ab69b3 100644 --- a/plugins/notifications-backend/migrations/20240221_removeDone.js +++ b/plugins/notifications-backend/migrations/20240221_removeDone.js @@ -14,6 +14,11 @@ * limitations under the License. */ +// @ts-check + +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.alterTable('notification', table => { table.text('link').nullable().alter(); @@ -21,6 +26,9 @@ exports.up = async function up(knex) { }); }; +/** + * @param {import('knex').Knex} knex + */ exports.down = async function down(knex) { await knex.schema.alterTable('notification', table => { table.text('link').notNullable().alter(); diff --git a/plugins/notifications-backend/migrations/20240313_broadcast.js b/plugins/notifications-backend/migrations/20240313_broadcast.js index 8b9ddeb24d..dd3ecd58cc 100644 --- a/plugins/notifications-backend/migrations/20240313_broadcast.js +++ b/plugins/notifications-backend/migrations/20240313_broadcast.js @@ -14,6 +14,11 @@ * limitations under the License. */ +// @ts-check + +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.createTable('broadcast', table => { table.uuid('id').primary(); @@ -37,7 +42,7 @@ exports.up = async function up(knex) { table .foreign('broadcast_id') - .references(['id']) + .references('id') .inTable('broadcast') .onDelete('CASCADE'); table.unique(['broadcast_id', 'user'], { diff --git a/plugins/notifications-backend/migrations/20240808_settings.js b/plugins/notifications-backend/migrations/20240808_settings.js index 4d4fbc24cd..8d2351d0c5 100644 --- a/plugins/notifications-backend/migrations/20240808_settings.js +++ b/plugins/notifications-backend/migrations/20240808_settings.js @@ -13,6 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// @ts-check + +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.createTable('user_settings', table => { table.string('user').notNullable(); diff --git a/plugins/notifications-backend/migrations/20240902_addIcon.js b/plugins/notifications-backend/migrations/20240902_addIcon.js index a5327f8d73..f57948e08a 100644 --- a/plugins/notifications-backend/migrations/20240902_addIcon.js +++ b/plugins/notifications-backend/migrations/20240902_addIcon.js @@ -14,6 +14,11 @@ * limitations under the License. */ +// @ts-check + +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.alterTable('notification', table => { table.string('icon', 255).nullable(); @@ -23,6 +28,9 @@ exports.up = async function up(knex) { }); }; +/** + * @param {import('knex').Knex} knex + */ exports.down = async function down(knex) { await knex.schema.alterTable('notification', table => { table.dropColumn('icon'); diff --git a/plugins/notifications-backend/migrations/20250317_addTopic.js b/plugins/notifications-backend/migrations/20250317_addTopic.js index e17b8d0789..c2d4d7b10e 100644 --- a/plugins/notifications-backend/migrations/20250317_addTopic.js +++ b/plugins/notifications-backend/migrations/20250317_addTopic.js @@ -13,8 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// @ts-check + const crypto = require('crypto'); +/** + * @param {import('knex').Knex} knex + */ exports.up = async function up(knex) { await knex.schema.alterTable('user_settings', table => { table.string('topic').nullable().after('origin'); @@ -41,6 +47,9 @@ exports.up = async function up(knex) { }); }; +/** + * @param {import('knex').Knex} knex + */ exports.down = async function down(knex) { await knex.schema.table('user_settings', table => { table.dropUnique([], 'user_settings_unique_idx');