mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-07 18:15:49 +08:00
typescript
This commit is contained in:
@@ -70,8 +70,8 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
const startedAt = toISO(items[0].createdAt)
|
||||
const updatedAt = toISO(items[items.length - 1].createdAt)
|
||||
const startedAt = toISO(items[0]?.createdAt)
|
||||
const updatedAt = toISO(items[items.length - 1]?.createdAt)
|
||||
const callsign = extractCallsign(items)
|
||||
|
||||
return {
|
||||
|
||||
@@ -16,7 +16,7 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Missing user ID' })
|
||||
}
|
||||
|
||||
const body = await readBody<UpdateNotesBody>(event).catch(() => ({}))
|
||||
const body = await readBody<UpdateNotesBody>(event).catch(() => ({}) as UpdateNotesBody)
|
||||
const rawNotes = typeof body.notes === 'string' ? body.notes.replace(/\r\n/g, '\n') : ''
|
||||
const notes = rawNotes.trim()
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Missing user ID' })
|
||||
}
|
||||
|
||||
const body = await readBody<UpdateRoleBody>(event).catch(() => ({}))
|
||||
const body = await readBody<UpdateRoleBody>(event).catch(() => ({}) as UpdateRoleBody)
|
||||
const role = body.role?.trim()
|
||||
|
||||
if (!role || !['user', 'admin', 'dev'].includes(role)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import mongoose from 'mongoose'
|
||||
import { createError, defineEventHandler, readBody } from 'h3'
|
||||
import { requireAdmin } from '../../../../utils/auth'
|
||||
import { WaitlistEntry } from '../../../../models/WaitlistEntry'
|
||||
@@ -48,7 +49,7 @@ export default defineEventHandler(async (event) => {
|
||||
createdBy: admin._id,
|
||||
})
|
||||
|
||||
entry.invitationCode = invitation._id
|
||||
entry.invitationCode = invitation._id as mongoose.Types.ObjectId
|
||||
}
|
||||
|
||||
entry.invitationSentAt = now
|
||||
|
||||
@@ -193,7 +193,6 @@ export default defineEventHandler(async (event) => {
|
||||
const tts = await normalize.audio.speech.create({
|
||||
model: TTS_MODEL,
|
||||
voice,
|
||||
format: "wav",
|
||||
input: normalized,
|
||||
speed
|
||||
});
|
||||
|
||||
@@ -99,10 +99,14 @@ export default defineEventHandler(async (event) => {
|
||||
const panY = body.layout.pan.y
|
||||
const parsedX = typeof panX === 'number' ? panX : Number(panX)
|
||||
const parsedY = typeof panY === 'number' ? panY : Number(panY)
|
||||
if (Number.isFinite(parsedX)) layout.pan = layout.pan || { x: 0, y: 0 }
|
||||
if (Number.isFinite(parsedX)) layout.pan.x = parsedX
|
||||
if (Number.isFinite(parsedY)) layout.pan = layout.pan || { x: 0, y: 0 }
|
||||
if (Number.isFinite(parsedY)) layout.pan.y = parsedY
|
||||
if (Number.isFinite(parsedX)) {
|
||||
layout.pan = layout.pan || { x: 0, y: 0 }
|
||||
layout.pan.x = parsedX
|
||||
}
|
||||
if (Number.isFinite(parsedY)) {
|
||||
layout.pan = layout.pan || { x: 0, y: 0 }
|
||||
layout.pan.y = parsedY
|
||||
}
|
||||
}
|
||||
if (Array.isArray(body.layout.groups)) {
|
||||
layout.groups = body.layout.groups
|
||||
@@ -125,7 +129,7 @@ export default defineEventHandler(async (event) => {
|
||||
bounds,
|
||||
}
|
||||
})
|
||||
.filter((group): group is NonNullable<typeof group> => Boolean(group))
|
||||
.filter((group: any): group is NonNullable<typeof group> => Boolean(group))
|
||||
}
|
||||
flow.layout = layout
|
||||
flow.markModified('layout')
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { serializeNodeDocument } from '../../../../../../services/decisionFlowService'
|
||||
import type {
|
||||
DecisionNodeCondition,
|
||||
DecisionNodeRole,
|
||||
DecisionNodeTrigger,
|
||||
DecisionNodeTransition,
|
||||
} from '~~/shared/types/decision'
|
||||
@@ -58,7 +59,7 @@ export default defineEventHandler(async (event) => {
|
||||
if (!ROLE_SET.has(role)) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'role must be pilot, atc or system' })
|
||||
}
|
||||
node.role = role
|
||||
node.role = role as DecisionNodeRole
|
||||
}
|
||||
|
||||
if (typeof body.phase === 'string' && body.phase.trim()) {
|
||||
@@ -84,7 +85,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
if (typeof body.autoBehavior === 'string') {
|
||||
node.autoBehavior = body.autoBehavior.trim() || undefined
|
||||
node.autoBehavior = (body.autoBehavior.trim() || undefined) as typeof node.autoBehavior
|
||||
}
|
||||
|
||||
if (Array.isArray(body.actions)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import mongoose from 'mongoose'
|
||||
import { createError, readBody } from 'h3'
|
||||
import { hashPassword, issueAuthTokens } from '../../../utils/auth'
|
||||
import { User } from '../../../models/User'
|
||||
@@ -70,7 +71,7 @@ export default defineEventHandler(async (event) => {
|
||||
...(waitlistNotes ? { adminNotes: waitlistNotes } : {}),
|
||||
})
|
||||
|
||||
invitation.usedBy = user._id
|
||||
invitation.usedBy = user._id as mongoose.Types.ObjectId
|
||||
invitation.usedAt = now
|
||||
await invitation.save()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import mongoose from 'mongoose'
|
||||
import { defineEventHandler } from 'h3'
|
||||
import { InvitationCode } from '../../../models/InvitationCode'
|
||||
import { WaitlistEntry } from '../../../models/WaitlistEntry'
|
||||
@@ -51,7 +52,7 @@ export default defineEventHandler(async () => {
|
||||
channel: 'admin',
|
||||
label: `Waitlist: ${email}`,
|
||||
})
|
||||
entry.invitationCode = invitation._id
|
||||
entry.invitationCode = invitation._id as mongoose.Types.ObjectId
|
||||
}
|
||||
|
||||
entry.invitationSentAt = sentAt
|
||||
|
||||
@@ -23,7 +23,7 @@ function safeComparePassword(provided: string, expected: string) {
|
||||
return timingSafeEqual(providedDigest, expectedDigest)
|
||||
}
|
||||
|
||||
export default defineEventHandler<ManualInviteResponse>(async (event) => {
|
||||
export default defineEventHandler(async (event): Promise<ManualInviteResponse> => {
|
||||
const config = useRuntimeConfig()
|
||||
const expectedPassword = (config.manualInvitePassword as string | undefined)?.trim() || ''
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
|
||||
const dataEntries = [
|
||||
['Title', title],
|
||||
['Description', details],
|
||||
['Email', email || null],
|
||||
['Contact allowed', allowContact],
|
||||
['Title', title] as const,
|
||||
['Description', details] as const,
|
||||
['Email', email || null] as const,
|
||||
['Contact allowed', allowContact] as const,
|
||||
]
|
||||
|
||||
await sendAdminNotification({
|
||||
@@ -59,6 +59,6 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
return {
|
||||
success: true,
|
||||
suggestionId: suggestion._id.toString(),
|
||||
suggestionId: String(suggestion._id),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -214,8 +214,9 @@ function createFeature(element: OsmElement): AirportFeature | null {
|
||||
|
||||
if (lat === undefined || lon === undefined) return null
|
||||
|
||||
const { aliases, primaryAlias } = buildAliases(tags, featureType)
|
||||
if (aliases.length === 0 || !primaryAlias) return null
|
||||
const aliasResult = buildAliases(tags, featureType)
|
||||
if (aliasResult.aliases.length === 0 || !aliasResult.primaryAlias) return null
|
||||
const { aliases, primaryAlias } = aliasResult as { aliases: string[]; primaryAlias: string }
|
||||
|
||||
const normalizedAliases = new Map<string, string>()
|
||||
for (const alias of aliases) {
|
||||
|
||||
@@ -20,9 +20,7 @@ export default defineEventHandler(async () => {
|
||||
try {
|
||||
const response = await client.chat.completions.create({
|
||||
model,
|
||||
reasoning_effort: 'low',
|
||||
n: 1,
|
||||
verbosity: 'low',
|
||||
messages: [
|
||||
{ role: 'system', content: SYSTEM_PROMPT },
|
||||
{ role: 'user', content: `${READBACK}` }
|
||||
|
||||
Reference in New Issue
Block a user