Revert "style: lint"

This reverts commit 98f40d7d0b.
This commit is contained in:
Neko Ayaka
2026-08-26 20:13:10 +08:00
parent cfcfc513ef
commit 146b3da65a
1625 changed files with 75440 additions and 75453 deletions
+53 -53
View File
@@ -1,26 +1,18 @@
export const ServerErrorMessages = {
invalidEventFormat: 'invalid event format',
invalidToken: 'invalid token',
mustAuthenticateBeforeAnnouncing: 'must authenticate before announcing',
moduleAnnounceIdentityInvalid: 'extension module identity must include an extension id for event \'extension:module:announce\'',
moduleAnnounceIndexInvalid: 'the field \'index\' must be a non-negative integer for event \'extension:module:announce\'',
moduleAnnounceNameInvalid: 'the field \'name\' must be a non-empty string for event \'extension:module:announce\'',
moduleConsumerEventInvalid: 'the field \'event\' must be a non-empty string for event consumer registration',
moduleNotFound: 'module not found, it hasn\'t announced itself or the name is incorrect',
mustAuthenticateBeforeAnnouncing: 'must authenticate before announcing',
noConsumerRegistered: 'no consumer registered for requested event delivery',
notAuthenticated: 'not authenticated',
uiConfigureModuleIndexInvalid: 'the field \'moduleIndex\' must be a non-negative integer for event \'ui:configure\'',
uiConfigureModuleNameInvalid: 'the field \'moduleName\' can\'t be empty for event \'ui:configure\'',
} as const
export interface ParsedServerErrorMessage {
authentication: boolean
code: ServerErrorCode
message: string
recoverable: boolean
terminal: boolean
}
export type ServerErrorCode
= | 'invalid-event-format'
| 'invalid-json'
@@ -37,6 +29,14 @@ export type ServerErrorCode
| 'ui-configure-module-name-invalid'
| 'unknown'
export interface ParsedServerErrorMessage {
authentication: boolean
code: ServerErrorCode
message: string
recoverable: boolean
terminal: boolean
}
export function createInvalidJsonServerErrorMessage(errorMessage: string) {
return `invalid JSON, error: ${errorMessage}`
}
@@ -47,27 +47,27 @@ export function createInvalidJsonServerErrorMessage(errorMessage: string) {
* @internal
*/
const errorMetadataRegistry: Record<string, Omit<ParsedServerErrorMessage, 'message'>> = {
[ServerErrorMessages.invalidEventFormat]: {
authentication: false,
code: 'invalid-event-format',
recoverable: false,
terminal: false,
},
[ServerErrorMessages.invalidToken]: {
authentication: true,
code: 'invalid-token',
recoverable: false,
terminal: true,
},
[ServerErrorMessages.moduleAnnounceIdentityInvalid]: {
authentication: false,
code: 'module-announce-identity-invalid',
recoverable: false,
[ServerErrorMessages.notAuthenticated]: {
authentication: true,
code: 'not-authenticated',
recoverable: true,
terminal: false,
},
[ServerErrorMessages.moduleAnnounceIndexInvalid]: {
[ServerErrorMessages.mustAuthenticateBeforeAnnouncing]: {
authentication: true,
code: 'must-authenticate-before-announcing',
recoverable: true,
terminal: false,
},
[ServerErrorMessages.invalidEventFormat]: {
authentication: false,
code: 'module-announce-index-invalid',
code: 'invalid-event-format',
recoverable: false,
terminal: false,
},
@@ -77,9 +77,15 @@ const errorMetadataRegistry: Record<string, Omit<ParsedServerErrorMessage, 'mess
recoverable: false,
terminal: false,
},
[ServerErrorMessages.moduleConsumerEventInvalid]: {
[ServerErrorMessages.moduleAnnounceIndexInvalid]: {
authentication: false,
code: 'module-consumer-event-invalid',
code: 'module-announce-index-invalid',
recoverable: false,
terminal: false,
},
[ServerErrorMessages.moduleAnnounceIdentityInvalid]: {
authentication: false,
code: 'module-announce-identity-invalid',
recoverable: false,
terminal: false,
},
@@ -89,10 +95,10 @@ const errorMetadataRegistry: Record<string, Omit<ParsedServerErrorMessage, 'mess
recoverable: false,
terminal: false,
},
[ServerErrorMessages.mustAuthenticateBeforeAnnouncing]: {
authentication: true,
code: 'must-authenticate-before-announcing',
recoverable: true,
[ServerErrorMessages.moduleConsumerEventInvalid]: {
authentication: false,
code: 'module-consumer-event-invalid',
recoverable: false,
terminal: false,
},
[ServerErrorMessages.noConsumerRegistered]: {
@@ -101,10 +107,10 @@ const errorMetadataRegistry: Record<string, Omit<ParsedServerErrorMessage, 'mess
recoverable: true,
terminal: false,
},
[ServerErrorMessages.notAuthenticated]: {
authentication: true,
code: 'not-authenticated',
recoverable: true,
[ServerErrorMessages.uiConfigureModuleNameInvalid]: {
authentication: false,
code: 'ui-configure-module-name-invalid',
recoverable: false,
terminal: false,
},
[ServerErrorMessages.uiConfigureModuleIndexInvalid]: {
@@ -113,28 +119,6 @@ const errorMetadataRegistry: Record<string, Omit<ParsedServerErrorMessage, 'mess
recoverable: false,
terminal: false,
},
[ServerErrorMessages.uiConfigureModuleNameInvalid]: {
authentication: false,
code: 'ui-configure-module-name-invalid',
recoverable: false,
terminal: false,
},
}
/**
* Checks if a server error message is authentication-related.
*/
export function isAuthenticationServerErrorMessage(message: string) {
return parseServerErrorMessage(message).authentication
}
/**
* Checks if a server error message is a terminal authentication error.
* Terminal errors should not be retried.
*/
export function isTerminalAuthenticationServerErrorMessage(message: string) {
const parsed = parseServerErrorMessage(message)
return parsed.authentication && parsed.terminal
}
/**
@@ -177,3 +161,19 @@ export function parseServerErrorMessage(message: string): ParsedServerErrorMessa
terminal: false,
}
}
/**
* Checks if a server error message is authentication-related.
*/
export function isAuthenticationServerErrorMessage(message: string) {
return parseServerErrorMessage(message).authentication
}
/**
* Checks if a server error message is a terminal authentication error.
* Terminal errors should not be retried.
*/
export function isTerminalAuthenticationServerErrorMessage(message: string) {
const parsed = parseServerErrorMessage(message)
return parsed.authentication && parsed.terminal
}
@@ -2,51 +2,51 @@ import type { MetadataEventSource, ProtocolEvents, RouteConfig, WebSocketEventSo
export * from '@proj-airi/plugin-protocol/types'
export interface WebSocketBaseEvent<T, D, S extends string = string> {
data: D
metadata: {
event: {
id: string
parentId?: string
}
source: MetadataEventSource
}
route?: RouteConfig
/**
* @deprecated Prefer metadata.source.
*/
source?: S | WebSocketEventSource
type: T
}
export type WebSocketEvent<C = undefined> = {
[K in keyof WebSocketEvents<C>]: WebSocketBaseEvent<K, WebSocketEvents<C>[K]>;
}[keyof WebSocketEvents<C>]
export interface WebSocketEventBaseMetadata {
source?: MetadataEventSource
event?: {
id?: string
parentId?: string
}
source?: MetadataEventSource
}
export interface WebSocketBaseEvent<T, D, S extends string = string> {
type: T
data: D
/**
* @deprecated Prefer metadata.source.
*/
source?: WebSocketEventSource | S
metadata: {
source: MetadataEventSource
event: {
id: string
parentId?: string
}
}
route?: RouteConfig
}
export interface WebSocketEvents<C = undefined> extends ProtocolEvents<C> {}
export type WebSocketEventDataInputs
= | WebSocketEvents['input:text']
| WebSocketEvents['input:text:voice']
| WebSocketEvents['input:voice']
export type WebSocketEventInputs
= | WebSocketEventOf<'input:text'>
| WebSocketEventOf<'input:text:voice'>
| WebSocketEventOf<'input:voice'>
export type WebSocketEventOf<E, C = undefined> = E extends keyof WebSocketEvents<C>
? Omit<WebSocketBaseEvent<E, WebSocketEvents<C>[E]>, 'metadata'> & { metadata?: WebSocketEventBaseMetadata }
: never
export type WebSocketEvent<C = undefined> = {
[K in keyof WebSocketEvents<C>]: WebSocketBaseEvent<K, WebSocketEvents<C>[K]>;
}[keyof WebSocketEvents<C>]
export type WebSocketEventOptionalSource<C = undefined> = {
[K in keyof WebSocketEvents<C>]: Omit<WebSocketBaseEvent<K, WebSocketEvents<C>[K]>, 'metadata'> & { metadata?: WebSocketEventBaseMetadata };
}[keyof WebSocketEvents<C>]
export interface WebSocketEvents<C = undefined> extends ProtocolEvents<C> {}
export type WebSocketEventOf<E, C = undefined> = E extends keyof WebSocketEvents<C>
? Omit<WebSocketBaseEvent<E, WebSocketEvents<C>[E]>, 'metadata'> & { metadata?: WebSocketEventBaseMetadata }
: never
export type WebSocketEventInputs
= | WebSocketEventOf<'input:text'>
| WebSocketEventOf<'input:text:voice'>
| WebSocketEventOf<'input:voice'>