UNPKG

@energica-city/shared-amplify-utils

Version:

Shared utilities for AWS Amplify projects

29 lines 2.41 kB
import type { AmplifyModelType, QueryFactoryResult } from '../../queries/types'; /** * Shared middleware utilities for REST, WebSocket, and GraphQL. * Centralizes common helpers and generic types to reduce duplication. */ export type ModelsResult<TTypes extends Record<string, AmplifyModelType>, TSelected extends keyof TTypes & string> = { [K in TSelected]: QueryFactoryResult<K, TTypes>; }; export interface MinimalLambdaContext { awsRequestId?: string; functionName?: string; functionVersion?: string; } export interface InputWithModels<TTypes extends Record<string, AmplifyModelType>, TSelected extends keyof TTypes & string, TEvent, TCtx extends MinimalLambdaContext> { event: TEvent; context: TCtx; models?: ModelsResult<TTypes, TSelected>; } export declare function ensureStructuredLogging(): void; export declare function setupStructuredLoggingWith<TTypes extends Record<string, AmplifyModelType>, TSelected extends keyof TTypes & string, TEvent, TCtx extends MinimalLambdaContext>(input: InputWithModels<TTypes, TSelected, TEvent, TCtx>, buildContext: (input: InputWithModels<TTypes, TSelected, TEvent, TCtx>, extra?: Record<string, unknown>) => Record<string, unknown>, forceStructuredLogging?: boolean, defaultContext?: Record<string, unknown>): void; export declare function getErrorMessage(error: unknown): string; export declare function getErrorStack(error: unknown): string | undefined; export declare function parseJsonBody(body: string | undefined, context: Record<string, unknown>, scope?: 'REST' | 'WebSocket' | string): unknown; export declare function buildErrorContextWith<TTypes extends Record<string, AmplifyModelType>, TSelected extends keyof TTypes & string, TEvent, TCtx extends MinimalLambdaContext>(input: InputWithModels<TTypes, TSelected, TEvent, TCtx>, buildContext: (input: InputWithModels<TTypes, TSelected, TEvent, TCtx>, extra?: Record<string, unknown>) => Record<string, unknown>, error: { code?: string; statusCode?: number; } | null, additionalContext?: Record<string, unknown>): Record<string, unknown>; export declare function getModelsFromInput<TTypes extends Record<string, AmplifyModelType>, TSelected extends keyof TTypes & string, TEvent, TCtx extends MinimalLambdaContext>(input: InputWithModels<TTypes, TSelected, TEvent, TCtx>, missingMessage: string): ModelsResult<TTypes, TSelected>; //# sourceMappingURL=common.d.ts.map