mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 09:16:26 +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}` }
|
||||
|
||||
@@ -154,8 +154,8 @@ export const takeoffEddf: FlightLabScenario = {
|
||||
],
|
||||
simConditions: {
|
||||
conditions: [
|
||||
{ variable: 'TURB_ENG_N1_1', operator: '>=', value: 85 },
|
||||
{ variable: 'TURB_ENG_N1_2', operator: '>=', value: 85 },
|
||||
{ variable: 'TURB_ENG_N1_1', operator: '>=', value: 80 },
|
||||
{ variable: 'TURB_ENG_N1_2', operator: '>=', value: 80 },
|
||||
{ variable: 'BRAKE_PARKING_POSITION', operator: '==', value: false },
|
||||
],
|
||||
logic: 'AND',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createBaseScenario, createScenarioSeries, digitsToWords, formatTemp, lettersToNato } from '~~/shared/learn/scenario'
|
||||
import type { ModuleDef, Scenario } from '~~/shared/learn/types'
|
||||
import type { Lesson, ModuleDef, Scenario } from '~~/shared/learn/types'
|
||||
|
||||
function gradientArt(colors: string[]): string {
|
||||
const stops = colors
|
||||
@@ -14,7 +14,7 @@ function randInt(min: number, max: number): number {
|
||||
}
|
||||
|
||||
function sample<T>(values: readonly T[]): T {
|
||||
return values[randInt(0, values.length - 1)]
|
||||
return values[randInt(0, values.length - 1)]!
|
||||
}
|
||||
|
||||
const identifierCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
||||
@@ -75,7 +75,7 @@ function createComplexTaxiScenario(): Scenario {
|
||||
return scenario
|
||||
}
|
||||
|
||||
const fundamentalsLessons = [
|
||||
const fundamentalsLessons: Lesson[] = [
|
||||
{
|
||||
id: 'icao-alphabet',
|
||||
title: 'Decode ICAO Letters & Numbers',
|
||||
@@ -564,7 +564,7 @@ const fundamentalsLessons = [
|
||||
}
|
||||
]
|
||||
|
||||
const readbackLessons = [
|
||||
const readbackLessons: Lesson[] = [
|
||||
{
|
||||
id: 'clearance-readback',
|
||||
title: 'Clearance Readback',
|
||||
@@ -1810,7 +1810,7 @@ const readbackLessons = [
|
||||
}
|
||||
]
|
||||
|
||||
const decisionTreeLessons = [
|
||||
const decisionTreeLessons: Lesson[] = [
|
||||
{
|
||||
id: 'clearance-contact',
|
||||
title: 'Delivery: Initial contact',
|
||||
@@ -2534,7 +2534,7 @@ const makeFullFlightGenerator = (reset = false) => () => {
|
||||
return fullFlightScenario()
|
||||
}
|
||||
|
||||
const fullFlightLessons = [
|
||||
const fullFlightLessons: Lesson[] = [
|
||||
{
|
||||
id: 'full-clearance-contact',
|
||||
title: 'Delivery Contact',
|
||||
|
||||
21
types/aos.d.ts
vendored
Normal file
21
types/aos.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
declare module 'aos' {
|
||||
interface AOSOptions {
|
||||
offset?: number
|
||||
delay?: number | string
|
||||
duration?: number | string
|
||||
easing?: string
|
||||
once?: boolean
|
||||
mirror?: boolean
|
||||
anchorPlacement?: string
|
||||
disable?: boolean | string | (() => boolean)
|
||||
}
|
||||
|
||||
interface AOS {
|
||||
init(options?: AOSOptions): void
|
||||
refresh(force?: boolean): void
|
||||
refreshHard(): void
|
||||
}
|
||||
|
||||
const aos: AOS
|
||||
export default aos
|
||||
}
|
||||
Reference in New Issue
Block a user