Files
speckle-server/packages/server/modules/cli/commands/bull/test-push.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

42 lines
1.3 KiB
TypeScript

import { cliLogger } from '@/observability/logging'
import type { MentionedInCommentData } from '@/modules/notifications/helpers/types'
import { NotificationType } from '@/modules/notifications/helpers/types'
import { publishNotification } from '@/modules/notifications/services/publication'
import { initializeQueue } from '@/modules/notifications/services/queue'
import type { CommandModule } from 'yargs'
const command: CommandModule = {
command: 'test-push [message] [error]',
describe: 'Push a fake notification onto the queue',
builder(yargs) {
return yargs
.positional('message', {
describe: 'Random message to push',
type: 'string',
default: 'Hello world!'
})
.positional('error', {
describe: 'Whether to throw error in handler, causing a re-queue',
type: 'boolean',
default: false
})
},
handler: async (argv) => {
await initializeQueue()
// we don't want to submit a real mentions payload, this is for testing only
await publishNotification(NotificationType.MentionedInComment, {
targetUserId: '123',
data: {
text: argv.message,
timestamp: new Date().toISOString(),
error: argv.error
} as unknown as MentionedInCommentData
})
cliLogger.info('Queued a fake notification...')
}
}
export = command