@cosmneo/onion-lasagna 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-XWKHOLIP.js → chunk-4HMXTGHK.js} +2 -2
- package/dist/chunk-4RFWJ5XZ.js +192 -0
- package/dist/chunk-4RFWJ5XZ.js.map +1 -0
- package/dist/{chunk-4BVOLXDJ.js → chunk-4YBAV6LZ.js} +2 -2
- package/dist/chunk-ANLXZHUS.js +230 -0
- package/dist/chunk-ANLXZHUS.js.map +1 -0
- package/dist/chunk-BG2FY27M.js +36 -0
- package/dist/chunk-BG2FY27M.js.map +1 -0
- package/dist/chunk-FEY2GSVT.js +1 -0
- package/dist/chunk-FEY2GSVT.js.map +1 -0
- package/dist/{chunk-2BVCU32G.js → chunk-HNEAH6OZ.js} +121 -2
- package/dist/chunk-HNEAH6OZ.js.map +1 -0
- package/dist/chunk-NQMFWI6Q.js +1 -0
- package/dist/chunk-NQMFWI6Q.js.map +1 -0
- package/dist/chunk-TZRBETT3.js +127 -0
- package/dist/chunk-TZRBETT3.js.map +1 -0
- package/dist/{chunk-MF2JDREK.js → chunk-UNVB4INM.js} +1 -1
- package/dist/{chunk-MF2JDREK.js.map → chunk-UNVB4INM.js.map} +1 -1
- package/dist/chunk-VBG3UYQR.js +119 -0
- package/dist/chunk-VBG3UYQR.js.map +1 -0
- package/dist/events/index.js +3 -4
- package/dist/events/server/index.js +3 -4
- package/dist/events/shared/index.js +2 -3
- package/dist/graphql/field/index.cjs +189 -0
- package/dist/graphql/field/index.cjs.map +1 -0
- package/dist/graphql/field/index.d.cts +214 -0
- package/dist/graphql/field/index.d.ts +214 -0
- package/dist/graphql/field/index.js +25 -0
- package/dist/graphql/field/index.js.map +1 -0
- package/dist/graphql/index.cjs +1148 -0
- package/dist/graphql/index.cjs.map +1 -0
- package/dist/graphql/index.d.cts +8 -0
- package/dist/graphql/index.d.ts +8 -0
- package/dist/graphql/index.js +49 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/sdl/index.cjs +241 -0
- package/dist/graphql/sdl/index.cjs.map +1 -0
- package/dist/graphql/sdl/index.d.cts +77 -0
- package/dist/graphql/sdl/index.d.ts +77 -0
- package/dist/graphql/sdl/index.js +8 -0
- package/dist/graphql/sdl/index.js.map +1 -0
- package/dist/graphql/server/index.cjs +505 -0
- package/dist/graphql/server/index.cjs.map +1 -0
- package/dist/graphql/server/index.d.cts +268 -0
- package/dist/graphql/server/index.d.ts +268 -0
- package/dist/graphql/server/index.js +15 -0
- package/dist/graphql/server/index.js.map +1 -0
- package/dist/graphql/shared/index.cjs +586 -0
- package/dist/graphql/shared/index.cjs.map +1 -0
- package/dist/graphql/shared/index.d.cts +82 -0
- package/dist/graphql/shared/index.d.ts +82 -0
- package/dist/graphql/shared/index.js +16 -0
- package/dist/graphql/shared/index.js.map +1 -0
- package/dist/http/index.cjs.map +1 -1
- package/dist/http/index.js +2 -3
- package/dist/http/route/index.cjs.map +1 -1
- package/dist/http/route/index.d.cts +4 -0
- package/dist/http/route/index.d.ts +4 -0
- package/dist/http/route/index.js +1 -1
- package/dist/http/shared/index.js +1 -2
- package/dist/index.cjs +672 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/schema-definition.type-C9PntBVc.d.cts +166 -0
- package/dist/schema-definition.type-CuhQLDr0.d.ts +166 -0
- package/package.json +31 -1
- package/dist/chunk-2BVCU32G.js.map +0 -1
- package/dist/chunk-H5TNDC5U.js +0 -138
- package/dist/chunk-H5TNDC5U.js.map +0 -1
- /package/dist/{chunk-XWKHOLIP.js.map → chunk-4HMXTGHK.js.map} +0 -0
- /package/dist/{chunk-4BVOLXDJ.js.map → chunk-4YBAV6LZ.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/graphql/index.ts","../../src/presentation/graphql/field/define-field.ts","../../src/presentation/graphql/field/types/schema-definition.type.ts","../../src/presentation/graphql/field/define-schema.ts","../../src/presentation/graphql/field/utils.ts","../../src/global/exceptions/coded-error.error.ts","../../src/global/exceptions/error-codes.const.ts","../../src/global/exceptions/object-validation.error.ts","../../src/domain/exceptions/domain.error.ts","../../src/app/exceptions/use-case.error.ts","../../src/app/exceptions/not-found.error.ts","../../src/app/exceptions/conflict.error.ts","../../src/app/exceptions/unprocessable.error.ts","../../src/app/exceptions/forbidden.error.ts","../../src/app/exceptions/unauthorized.error.ts","../../src/infra/exceptions/infra.error.ts","../../src/presentation/exceptions/access-denied.error.ts","../../src/presentation/http/shared/error-mapping.ts","../../src/presentation/graphql/shared/error-mapping.ts","../../src/presentation/graphql/server/types.ts","../../src/presentation/graphql/server/create-graphql-routes.ts","../../src/presentation/graphql/server/graphql-routes-builder.ts","../../src/presentation/graphql/sdl/generate.ts"],"sourcesContent":["// Field layer: defineQuery, defineMutation, defineSubscription, defineGraphQLSchema, mergeGraphQLSchemas\nexport {\n defineQuery,\n defineMutation,\n defineSubscription,\n defineGraphQLSchema,\n mergeGraphQLSchemas,\n generateFieldId,\n} from './field';\nexport type {\n DefineGraphQLSchemaOptions,\n GraphQLOperationType,\n GraphQLFieldDocumentation,\n GraphQLFieldDefinition,\n GraphQLSchemaEntry,\n GraphQLSchemaConfig,\n GraphQLSchemaDefaults,\n GraphQLSchemaDefinition,\n FlattenSchema,\n SchemaKeys,\n GetField,\n DeepMergeSchemas,\n DeepMergeSchemasAll,\n InferFieldOperation,\n InferFieldInput,\n InferFieldOutput,\n InferFieldContext,\n} from './field';\nexport { isFieldDefinition, isSchemaDefinition, collectFields } from './field';\n\n// Server layer: graphqlRoutes builder\nexport { graphqlRoutes } from './server';\nexport type {\n GraphQLRoutesBuilder,\n MissingHandlersError,\n BuilderGraphQLHandlerConfig,\n ValidatedArgs,\n TypedGraphQLContext,\n GraphQLHandlerContext,\n GraphQLHandlerConfig,\n SimpleGraphQLHandlerFn,\n SimpleGraphQLHandlerConfig,\n GraphQLMiddlewareFunction,\n CreateGraphQLRoutesOptions,\n UnifiedGraphQLField,\n UseCasePort,\n} from './server';\nexport { isSimpleGraphQLHandlerConfig } from './server';\n\n// SDL layer: schema definition language generation\nexport { generateGraphQLSDL } from './sdl';\nexport type { GraphQLSDLConfig } from './sdl';\n\n// Shared layer: error mapping\nexport type {\n GraphQLErrorCode,\n GraphQLErrorExtensions,\n GraphQLValidationErrorItem,\n MappedGraphQLError,\n} from './shared';\nexport { mapErrorToGraphQLError, getGraphQLErrorCode, shouldMaskGraphQLError } from './shared';\n","/**\n * @fileoverview Factory functions for creating GraphQL field definitions.\n *\n * `defineQuery`, `defineMutation`, and `defineSubscription` are the main entry\n * points for defining GraphQL fields. They mirror `defineRoute` /\n * `defineEventHandler` from the HTTP and event layers.\n *\n * @module graphql/field/define-field\n */\n\nimport type { SchemaAdapter, InferOutput } from '../../http/schema/types';\nimport type { GraphQLFieldDefinition, GraphQLOperationType } from './types';\n\n// ============================================================================\n// Input Types\n// ============================================================================\n\n/**\n * Input for defineQuery / defineMutation.\n *\n * @example Query with input and output\n * ```typescript\n * defineQuery({\n * input: zodSchema(z.object({ userId: z.string() })),\n * output: zodSchema(userSchema),\n * docs: { description: 'Get a user by ID' },\n * })\n * ```\n *\n * @example Mutation with context\n * ```typescript\n * defineMutation({\n * input: zodSchema(z.object({ name: z.string() })),\n * output: zodSchema(z.object({ id: z.string() })),\n * context: zodSchema(executionContextSchema),\n * docs: { description: 'Create a project' },\n * })\n * ```\n */\ninterface DefineFieldInput<\n TInput extends SchemaAdapter | undefined = undefined,\n TOutput extends SchemaAdapter | undefined = undefined,\n TContext extends SchemaAdapter | undefined = undefined,\n> {\n /** Input arguments validation schema. */\n readonly input?: TInput;\n\n /** Output type validation schema. */\n readonly output?: TOutput;\n\n /** Context validation schema (e.g., JWT payload from middleware). */\n readonly context?: TContext;\n\n /** Field documentation. */\n readonly docs?: {\n readonly summary?: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly deprecated?: boolean;\n readonly deprecationReason?: string;\n };\n}\n\n// ============================================================================\n// Return type helpers\n// ============================================================================\n\ntype ResolveInput<T> = T extends SchemaAdapter ? InferOutput<T> : undefined;\ntype ResolveOutput<T> = T extends SchemaAdapter ? InferOutput<T> : undefined;\ntype ResolveContext<T> = T extends SchemaAdapter ? InferOutput<T> : undefined;\n\n// ============================================================================\n// Internal Factory\n// ============================================================================\n\nfunction createFieldDefinition<\n TOperation extends GraphQLOperationType,\n TInput extends SchemaAdapter | undefined = undefined,\n TOutput extends SchemaAdapter | undefined = undefined,\n TContext extends SchemaAdapter | undefined = undefined,\n>(\n operation: TOperation,\n input: DefineFieldInput<TInput, TOutput, TContext>,\n): GraphQLFieldDefinition<\n TOperation,\n ResolveInput<TInput>,\n ResolveOutput<TOutput>,\n ResolveContext<TContext>\n> {\n const definition = {\n operation,\n input: input.input ?? undefined,\n output: input.output ?? undefined,\n context: input.context ?? undefined,\n docs: {\n summary: input.docs?.summary,\n description: input.docs?.description,\n tags: input.docs?.tags,\n deprecated: input.docs?.deprecated ?? false,\n deprecationReason: input.docs?.deprecationReason,\n },\n _isGraphQLField: true as const,\n _types: undefined as unknown,\n };\n\n return Object.freeze(definition) as GraphQLFieldDefinition<\n TOperation,\n ResolveInput<TInput>,\n ResolveOutput<TOutput>,\n ResolveContext<TContext>\n >;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Creates a GraphQL query field definition.\n *\n * @param config - Field configuration with optional schemas\n * @returns A frozen GraphQLFieldDefinition with operation 'query'\n *\n * @example\n * ```typescript\n * const getUser = defineQuery({\n * input: zodSchema(z.object({ userId: z.string() })),\n * output: zodSchema(userSchema),\n * docs: { description: 'Get a user by ID' },\n * });\n * ```\n */\nexport function defineQuery<\n TInput extends SchemaAdapter | undefined = undefined,\n TOutput extends SchemaAdapter | undefined = undefined,\n TContext extends SchemaAdapter | undefined = undefined,\n>(\n config: DefineFieldInput<TInput, TOutput, TContext> = {},\n): GraphQLFieldDefinition<\n 'query',\n ResolveInput<TInput>,\n ResolveOutput<TOutput>,\n ResolveContext<TContext>\n> {\n return createFieldDefinition('query', config);\n}\n\n/**\n * Creates a GraphQL mutation field definition.\n *\n * @param config - Field configuration with optional schemas\n * @returns A frozen GraphQLFieldDefinition with operation 'mutation'\n *\n * @example\n * ```typescript\n * const createProject = defineMutation({\n * input: zodSchema(z.object({ name: z.string() })),\n * output: zodSchema(z.object({ id: z.string() })),\n * context: zodSchema(executionContextSchema),\n * docs: { description: 'Create a new project' },\n * });\n * ```\n */\nexport function defineMutation<\n TInput extends SchemaAdapter | undefined = undefined,\n TOutput extends SchemaAdapter | undefined = undefined,\n TContext extends SchemaAdapter | undefined = undefined,\n>(\n config: DefineFieldInput<TInput, TOutput, TContext> = {},\n): GraphQLFieldDefinition<\n 'mutation',\n ResolveInput<TInput>,\n ResolveOutput<TOutput>,\n ResolveContext<TContext>\n> {\n return createFieldDefinition('mutation', config);\n}\n\n/**\n * Creates a GraphQL subscription field definition.\n *\n * Subscription handlers return an `AsyncIterable` of values rather than\n * a single response. The output schema validates each emitted value.\n *\n * @param config - Field configuration with optional schemas\n * @returns A frozen GraphQLFieldDefinition with operation 'subscription'\n *\n * @example\n * ```typescript\n * const onTicketCreated = defineSubscription({\n * input: zodSchema(z.object({ projectId: z.string() })),\n * output: zodSchema(ticketSchema),\n * docs: { description: 'Subscribe to new tickets in a project' },\n * });\n * ```\n */\nexport function defineSubscription<\n TInput extends SchemaAdapter | undefined = undefined,\n TOutput extends SchemaAdapter | undefined = undefined,\n TContext extends SchemaAdapter | undefined = undefined,\n>(\n config: DefineFieldInput<TInput, TOutput, TContext> = {},\n): GraphQLFieldDefinition<\n 'subscription',\n ResolveInput<TInput>,\n ResolveOutput<TOutput>,\n ResolveContext<TContext>\n> {\n return createFieldDefinition('subscription', config);\n}\n","/**\n * @fileoverview GraphQL schema definition types for grouping fields.\n *\n * Mirrors the HTTP router definition pattern with hierarchical grouping,\n * dotted-key access, and deep merge support.\n *\n * @module graphql/field/types/schema-definition\n */\n\nimport type { GraphQLFieldDefinition, GraphQLOperationType } from './field-definition.type';\nimport type { SchemaAdapter } from '../../../http/schema/types';\n\n// ============================================================================\n// Schema Types\n// ============================================================================\n\n/**\n * A schema entry can be a field definition, a nested config, or a schema definition.\n */\nexport type GraphQLSchemaEntry =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | GraphQLFieldDefinition<GraphQLOperationType, any, any, any>\n | GraphQLSchemaConfig\n | GraphQLSchemaDefinition;\n\n/**\n * Configuration for a GraphQL schema (group of fields).\n */\nexport interface GraphQLSchemaConfig {\n readonly [key: string]: GraphQLSchemaEntry;\n}\n\n/**\n * Schema-level defaults applied to all child fields.\n */\nexport interface GraphQLSchemaDefaults {\n /** Default tags for all fields. Merged with field-specific tags. */\n readonly tags?: readonly string[];\n\n /** Default context schema. Applied to fields that don't define their own. */\n readonly context?: SchemaAdapter;\n}\n\n/**\n * A fully defined GraphQL schema.\n */\nexport interface GraphQLSchemaDefinition<T extends GraphQLSchemaConfig = GraphQLSchemaConfig> {\n /** The fields and nested groups in this schema. */\n readonly fields: T;\n\n /** Default values applied to all child fields. */\n readonly defaults?: GraphQLSchemaDefaults;\n\n /**\n * Marker to identify this as a GraphQL schema definition.\n * @internal\n */\n readonly _isGraphQLSchema: true;\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Checks if a value is a GraphQLFieldDefinition.\n */\nexport function isFieldDefinition(value: unknown): value is GraphQLFieldDefinition {\n return (\n typeof value === 'object' &&\n value !== null &&\n '_isGraphQLField' in value &&\n (value as GraphQLFieldDefinition)._isGraphQLField === true\n );\n}\n\n/**\n * Checks if a value is a GraphQLSchemaDefinition.\n */\nexport function isSchemaDefinition(value: unknown): value is GraphQLSchemaDefinition {\n return (\n typeof value === 'object' &&\n value !== null &&\n '_isGraphQLSchema' in value &&\n (value as GraphQLSchemaDefinition)._isGraphQLSchema === true\n );\n}\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\n/**\n * Flattens a schema into a map of dotted keys to field definitions.\n */\nexport type FlattenSchema<\n T extends GraphQLSchemaConfig,\n Prefix extends string = '',\n> = T extends GraphQLSchemaConfig\n ? {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends GraphQLFieldDefinition<any, any, any, any>\n ? { [P in `${Prefix}${K & string}`]: T[K] }\n : T[K] extends GraphQLSchemaConfig\n ? FlattenSchema<T[K], `${Prefix}${K & string}.`>\n : never;\n }[keyof T] extends infer U\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n U extends Record<string, GraphQLFieldDefinition<any, any, any, any>>\n ? U\n : never\n : never\n : never;\n\n/**\n * Gets all field keys from a schema.\n */\nexport type SchemaKeys<\n T extends GraphQLSchemaConfig,\n Prefix extends string = '',\n> = T extends GraphQLSchemaConfig\n ? {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends GraphQLFieldDefinition<any, any, any, any>\n ? `${Prefix}${K & string}`\n : T[K] extends GraphQLSchemaConfig\n ? SchemaKeys<T[K], `${Prefix}${K & string}.`>\n : never;\n }[keyof T]\n : never;\n\n/**\n * Gets a field by its dotted key path.\n */\nexport type GetField<\n T extends GraphQLSchemaConfig,\n K extends string,\n> = K extends `${infer Head}.${infer Tail}`\n ? Head extends keyof T\n ? T[Head] extends GraphQLSchemaConfig\n ? GetField<T[Head], Tail>\n : never\n : never\n : K extends keyof T\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T[K] extends GraphQLFieldDefinition<any, any, any, any>\n ? T[K]\n : never\n : never;\n\n// ============================================================================\n// Deep Merge Types\n// ============================================================================\n\n/**\n * Deep-merges two schema configs at the type level.\n */\nexport type DeepMergeSchemas<A extends GraphQLSchemaConfig, B extends GraphQLSchemaConfig> = {\n readonly [K in keyof A | keyof B]: K extends keyof A\n ? K extends keyof B\n ? A[K] extends GraphQLSchemaConfig\n ? B[K] extends GraphQLSchemaConfig\n ? DeepMergeSchemas<A[K], B[K]>\n : B[K]\n : B[K]\n : A[K]\n : K extends keyof B\n ? B[K]\n : never;\n};\n\n/**\n * Recursively deep-merges N schema configs left-to-right.\n */\nexport type DeepMergeSchemasAll<T extends readonly GraphQLSchemaConfig[]> = T extends readonly [\n infer Only extends GraphQLSchemaConfig,\n]\n ? Only\n : T extends readonly [\n infer First extends GraphQLSchemaConfig,\n infer Second extends GraphQLSchemaConfig,\n ...infer Rest extends readonly GraphQLSchemaConfig[],\n ]\n ? DeepMergeSchemasAll<[DeepMergeSchemas<First, Second>, ...Rest]>\n : GraphQLSchemaConfig;\n\n// ============================================================================\n// Runtime Utilities\n// ============================================================================\n\n/**\n * Collects all fields from a schema into a flat array.\n */\nexport function collectFields(\n config: GraphQLSchemaConfig,\n basePath = '',\n): { key: string; field: GraphQLFieldDefinition }[] {\n const fields: { key: string; field: GraphQLFieldDefinition }[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n const fullKey = basePath ? `${basePath}.${key}` : key;\n\n if (isFieldDefinition(value)) {\n fields.push({ key: fullKey, field: value });\n } else if (isSchemaDefinition(value)) {\n fields.push(...collectFields(value.fields, fullKey));\n } else if (typeof value === 'object' && value !== null) {\n fields.push(...collectFields(value as GraphQLSchemaConfig, fullKey));\n }\n }\n\n return fields;\n}\n","/**\n * @fileoverview Factory function for creating GraphQL schema definitions.\n *\n * The `defineGraphQLSchema` function groups fields into a hierarchical structure\n * with optional schema-level defaults for context and tags.\n *\n * @module graphql/field/define-schema\n */\n\nimport type {\n GraphQLSchemaConfig,\n GraphQLSchemaDefaults,\n GraphQLSchemaDefinition,\n GraphQLFieldDefinition,\n DeepMergeSchemas,\n DeepMergeSchemasAll,\n} from './types';\nimport { isFieldDefinition, isSchemaDefinition } from './types';\n\n/**\n * Options for schema definition.\n */\nexport interface DefineGraphQLSchemaOptions {\n /**\n * Default values applied to all child fields.\n *\n * @example\n * ```typescript\n * defineGraphQLSchema({\n * getUser: getUserQuery,\n * createUser: createUserMutation,\n * }, {\n * defaults: {\n * context: zodSchema(executionContextSchema),\n * tags: ['Users'],\n * },\n * })\n * ```\n */\n readonly defaults?: GraphQLSchemaDefaults;\n}\n\n/**\n * Creates a GraphQL schema definition from a configuration object.\n *\n * A schema is a hierarchical grouping of fields that provides:\n * - Organized API structure with nested namespaces\n * - Type-safe resolver registration\n * - Schema-level defaults for context and tags\n *\n * @param fields - Object containing fields and nested groups\n * @param options - Optional schema configuration\n * @returns A frozen GraphQLSchemaDefinition object\n *\n * @example Basic schema\n * ```typescript\n * const schema = defineGraphQLSchema({\n * users: {\n * get: getUserQuery,\n * list: listUsersQuery,\n * create: createUserMutation,\n * },\n * });\n * ```\n *\n * @example With defaults\n * ```typescript\n * const schema = defineGraphQLSchema({\n * get: getUserQuery,\n * list: listUsersQuery,\n * }, {\n * defaults: {\n * context: zodSchema(executionContextSchema),\n * tags: ['Users'],\n * },\n * });\n * ```\n */\nexport function defineGraphQLSchema<T extends GraphQLSchemaConfig>(\n fields: T,\n options?: DefineGraphQLSchemaOptions,\n): GraphQLSchemaDefinition<T> {\n const defaults = options?.defaults;\n\n // Apply defaults to fields if context or tags are provided\n const processedFields =\n defaults?.context || defaults?.tags ? (applySchemaDefaults(fields, defaults) as T) : fields;\n\n const definition: GraphQLSchemaDefinition<T> = {\n fields: processedFields,\n defaults,\n _isGraphQLSchema: true,\n };\n\n return deepFreeze(definition);\n}\n\n/**\n * Recursively applies schema-level defaults to all fields in the tree.\n */\nfunction applySchemaDefaults(\n config: GraphQLSchemaConfig,\n defaults: GraphQLSchemaDefaults,\n): GraphQLSchemaConfig {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(config)) {\n if (isFieldDefinition(value)) {\n result[key] = applyDefaultsToField(value, defaults);\n } else if (isSchemaDefinition(value)) {\n result[key] = {\n ...value,\n fields: applySchemaDefaults(value.fields, defaults),\n };\n } else if (typeof value === 'object' && value !== null) {\n result[key] = applySchemaDefaults(value as GraphQLSchemaConfig, defaults);\n }\n }\n\n return result as GraphQLSchemaConfig;\n}\n\n/**\n * Applies schema-level defaults to a single field definition.\n */\nfunction applyDefaultsToField(\n field: GraphQLFieldDefinition,\n defaults: GraphQLSchemaDefaults,\n): GraphQLFieldDefinition {\n const needsContext = defaults.context && !field.context;\n const needsTags = defaults.tags && defaults.tags.length > 0;\n\n if (!needsContext && !needsTags) return field;\n\n return Object.freeze({\n ...field,\n context: field.context ?? defaults.context ?? undefined,\n docs: {\n ...field.docs,\n tags: mergeTags(defaults.tags, field.docs.tags),\n },\n }) as GraphQLFieldDefinition;\n}\n\n/**\n * Merges schema-level tags with field-level tags, avoiding duplicates.\n */\nfunction mergeTags(\n schemaTags?: readonly string[],\n fieldTags?: readonly string[],\n): readonly string[] | undefined {\n if (!schemaTags || schemaTags.length === 0) return fieldTags;\n if (!fieldTags || fieldTags.length === 0) return schemaTags;\n\n const merged = [...schemaTags];\n for (const tag of fieldTags) {\n if (!merged.includes(tag)) {\n merged.push(tag);\n }\n }\n return merged;\n}\n\n/**\n * Deep freezes an object and all its nested objects.\n */\nfunction deepFreeze<T extends object>(obj: T): T {\n const propNames = Object.getOwnPropertyNames(obj) as (keyof T)[];\n\n for (const name of propNames) {\n const value = obj[name];\n if (value && typeof value === 'object' && !Object.isFrozen(value)) {\n deepFreeze(value);\n }\n }\n\n return Object.freeze(obj);\n}\n\n// ============================================================================\n// mergeGraphQLSchemas — variadic deep merge\n// ============================================================================\n\ntype SchemaInput<T extends GraphQLSchemaConfig> = T | GraphQLSchemaDefinition<T>;\n\n/** Extracts the raw GraphQLSchemaConfig from either a plain config or a GraphQLSchemaDefinition. */\nfunction extractFields<T extends GraphQLSchemaConfig>(input: SchemaInput<T>): T {\n return isSchemaDefinition(input) ? input.fields : input;\n}\n\n/** Returns true if `value` is a plain sub-group object (not a FieldDefinition, not a SchemaDefinition). */\nfunction isSubGroup(value: unknown): value is GraphQLSchemaConfig {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isFieldDefinition(value) &&\n !isSchemaDefinition(value)\n );\n}\n\n/** Recursively deep-merges two schema configs. Sub-groups are merged; leaves are overwritten. */\nfunction deepMergeConfigs(a: GraphQLSchemaConfig, b: GraphQLSchemaConfig): GraphQLSchemaConfig {\n const result: Record<string, unknown> = { ...a };\n\n for (const key of Object.keys(b)) {\n const aVal = result[key];\n const bVal = b[key];\n\n if (isSubGroup(aVal) && isSubGroup(bVal)) {\n result[key] = deepMergeConfigs(aVal, bVal);\n } else {\n result[key] = bVal;\n }\n }\n\n return result as GraphQLSchemaConfig;\n}\n\n// Overloads for 2–8 schemas (clean IDE experience)\nexport function mergeGraphQLSchemas<T1 extends GraphQLSchemaConfig, T2 extends GraphQLSchemaConfig>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n): GraphQLSchemaDefinition<DeepMergeSchemas<T1, T2>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3]>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3, T4]>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3, T4, T5]>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3, T4, T5, T6]>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3, T4, T5, T6, T7]>>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n T8 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n s8: SchemaInput<T8>,\n): GraphQLSchemaDefinition<DeepMergeSchemasAll<[T1, T2, T3, T4, T5, T6, T7, T8]>>;\n// Add overloads for 9-12 following the same pattern as define-router.ts\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n T8 extends GraphQLSchemaConfig,\n T9 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n s8: SchemaInput<T8>,\n s9: SchemaInput<T9>,\n): GraphQLSchemaDefinition<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<DeepMergeSchemas<DeepMergeSchemas<T1, T2>, T3>, T4>,\n T5\n >,\n T6\n >,\n T7\n >,\n T8\n >,\n T9\n >\n>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n T8 extends GraphQLSchemaConfig,\n T9 extends GraphQLSchemaConfig,\n T10 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n s8: SchemaInput<T8>,\n s9: SchemaInput<T9>,\n s10: SchemaInput<T10>,\n): GraphQLSchemaDefinition<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<DeepMergeSchemas<DeepMergeSchemas<T1, T2>, T3>, T4>,\n T5\n >,\n T6\n >,\n T7\n >,\n T8\n >,\n T9\n >,\n T10\n >\n>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n T8 extends GraphQLSchemaConfig,\n T9 extends GraphQLSchemaConfig,\n T10 extends GraphQLSchemaConfig,\n T11 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n s8: SchemaInput<T8>,\n s9: SchemaInput<T9>,\n s10: SchemaInput<T10>,\n s11: SchemaInput<T11>,\n): GraphQLSchemaDefinition<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<DeepMergeSchemas<DeepMergeSchemas<T1, T2>, T3>, T4>,\n T5\n >,\n T6\n >,\n T7\n >,\n T8\n >,\n T9\n >,\n T10\n >,\n T11\n >\n>;\nexport function mergeGraphQLSchemas<\n T1 extends GraphQLSchemaConfig,\n T2 extends GraphQLSchemaConfig,\n T3 extends GraphQLSchemaConfig,\n T4 extends GraphQLSchemaConfig,\n T5 extends GraphQLSchemaConfig,\n T6 extends GraphQLSchemaConfig,\n T7 extends GraphQLSchemaConfig,\n T8 extends GraphQLSchemaConfig,\n T9 extends GraphQLSchemaConfig,\n T10 extends GraphQLSchemaConfig,\n T11 extends GraphQLSchemaConfig,\n T12 extends GraphQLSchemaConfig,\n>(\n s1: SchemaInput<T1>,\n s2: SchemaInput<T2>,\n s3: SchemaInput<T3>,\n s4: SchemaInput<T4>,\n s5: SchemaInput<T5>,\n s6: SchemaInput<T6>,\n s7: SchemaInput<T7>,\n s8: SchemaInput<T8>,\n s9: SchemaInput<T9>,\n s10: SchemaInput<T10>,\n s11: SchemaInput<T11>,\n s12: SchemaInput<T12>,\n): GraphQLSchemaDefinition<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<\n DeepMergeSchemas<DeepMergeSchemas<DeepMergeSchemas<T1, T2>, T3>, T4>,\n T5\n >,\n T6\n >,\n T7\n >,\n T8\n >,\n T9\n >,\n T10\n >,\n T11\n >,\n T12\n >\n>;\n\n// Variadic fallback for 13+\nexport function mergeGraphQLSchemas(\n ...schemas: SchemaInput<GraphQLSchemaConfig>[]\n): GraphQLSchemaDefinition<GraphQLSchemaConfig>;\n\n// Implementation\nexport function mergeGraphQLSchemas(\n ...schemas: SchemaInput<GraphQLSchemaConfig>[]\n): GraphQLSchemaDefinition<GraphQLSchemaConfig> {\n const merged = schemas.map(extractFields).reduce(deepMergeConfigs);\n return defineGraphQLSchema(merged);\n}\n","/**\n * @fileoverview GraphQL field utility functions.\n *\n * @module graphql/field/utils\n */\n\n/**\n * Generates a field ID from a schema key path.\n *\n * This is the **single source of truth** for the naming convention used across:\n * - SDL generation (`type Query { usersGet(...) }`)\n * - Yoga resolver map keys\n * - Client query string field names\n *\n * Converts dotted key paths to camelCase:\n * - `\"users.get\"` → `\"usersGet\"`\n * - `\"projects.members.list\"` → `\"projectsMembersList\"`\n * - `\"getUser\"` → `\"getUser\"` (single segment unchanged)\n *\n * @param key - The dotted schema key path\n * @returns A camelCase field ID string\n */\nexport function generateFieldId(key: string): string {\n return key\n .split('.')\n .map((segment, index) =>\n index === 0 ? segment : segment.charAt(0).toUpperCase() + segment.slice(1),\n )\n .join('');\n}\n","import type { ErrorCode } from './error-codes.const';\n\n/**\n * Base error class for all application errors with a machine-readable code.\n *\n * Abstract class that extends the native `Error` with:\n * - A `code` property for programmatic error handling\n * - Optional `cause` for error chaining (ES2022 compatible)\n * - A `fromError` static factory pattern for error transformation\n *\n * **Why abstract:** Prevents non-declarative error usage. All errors must\n * be explicitly defined as subclasses to ensure consistent error taxonomy.\n *\n * @example Subclass implementation\n * ```typescript\n * class DbError extends InfraError {\n * static override fromError(cause: unknown): DbError {\n * return new DbError({\n * message: cause instanceof Error ? cause.message : 'Database error',\n * cause,\n * });\n * }\n * }\n * ```\n *\n * @example Usage with wrapErrorAsync\n * ```typescript\n * await wrapErrorAsync(\n * () => this.db.query(...),\n * DbError.fromError,\n * );\n * ```\n */\nexport abstract class CodedError extends Error {\n /** Machine-readable error code for programmatic handling. */\n public readonly code: ErrorCode | string;\n\n /**\n * Creates a new CodedError instance.\n *\n * @param options - Error configuration\n * @param options.message - Human-readable error message\n * @param options.code - Machine-readable error code from ErrorCodes registry or custom string\n * @param options.cause - Optional underlying error that caused this error\n */\n constructor({\n message,\n code,\n cause,\n }: {\n message: string;\n code: ErrorCode | string;\n cause?: unknown;\n }) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n if (cause !== undefined) {\n Object.defineProperty(this, 'cause', {\n value: cause,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n }\n }\n\n /**\n * Factory method to create a typed error from a caught error.\n *\n * Subclasses should override this to provide proper error transformation.\n * Designed for use with {@link wrapErrorAsync} and {@link wrapError}.\n *\n * @param _cause - The original caught error\n * @returns A new CodedError instance\n * @throws {Error} If not overridden by subclass\n *\n * @example\n * ```typescript\n * class NotFoundError extends UseCaseError {\n * static override fromError(cause: unknown): NotFoundError {\n * return new NotFoundError({\n * message: 'Resource not found',\n * cause,\n * });\n * }\n * }\n * ```\n */\n static fromError(_cause: unknown): CodedError {\n throw new Error(`${this.name}.fromError() must be implemented by subclass`);\n }\n}\n","/**\n * Centralized registry of all error codes used across the application.\n *\n * Error codes are grouped by architectural layer to maintain clear boundaries\n * and make it easy to identify where an error originated.\n *\n * @example Using error codes in custom errors\n * ```typescript\n * import { ErrorCodes } from '@cosmneo/onion-lasagna/global';\n *\n * throw new NotFoundError({\n * message: 'User not found',\n * code: ErrorCodes.App.NOT_FOUND,\n * });\n * ```\n *\n * @example Checking error codes programmatically\n * ```typescript\n * if (error.code === ErrorCodes.App.NOT_FOUND) {\n * // Handle not found case\n * }\n * ```\n */\nexport const ErrorCodes = {\n /**\n * Domain layer error codes.\n * Used for business rule violations and invariant failures.\n */\n Domain: {\n /** Generic domain error */\n DOMAIN_ERROR: 'DOMAIN_ERROR',\n /** Business invariant was violated */\n INVARIANT_VIOLATION: 'INVARIANT_VIOLATION',\n /** Aggregate was partially loaded (missing required relations) */\n PARTIAL_LOAD: 'PARTIAL_LOAD',\n },\n\n /**\n * Application layer (use case) error codes.\n * Used for orchestration failures and business operation errors.\n */\n App: {\n /** Generic use case error */\n USE_CASE_ERROR: 'USE_CASE_ERROR',\n /** Requested resource was not found */\n NOT_FOUND: 'NOT_FOUND',\n /** Resource state conflict (e.g., duplicate, already exists) */\n CONFLICT: 'CONFLICT',\n /** Request is valid but cannot be processed due to business rules */\n UNPROCESSABLE: 'UNPROCESSABLE',\n /** Authorization denied - user lacks permission for this operation */\n FORBIDDEN: 'FORBIDDEN',\n /** Authentication required or invalid - user is not authenticated */\n UNAUTHORIZED: 'UNAUTHORIZED',\n },\n\n /**\n * Infrastructure layer error codes.\n * Used for data access, external services, and I/O failures.\n */\n Infra: {\n /** Generic infrastructure error */\n INFRA_ERROR: 'INFRA_ERROR',\n /** Database operation failed */\n DB_ERROR: 'DB_ERROR',\n /** Network connectivity or communication error */\n NETWORK_ERROR: 'NETWORK_ERROR',\n /** Operation timed out */\n TIMEOUT_ERROR: 'TIMEOUT_ERROR',\n /** External/third-party service error */\n EXTERNAL_SERVICE_ERROR: 'EXTERNAL_SERVICE_ERROR',\n },\n\n /**\n * Presentation layer error codes.\n * Used for controller, request handling, and authorization errors.\n */\n Presentation: {\n /** Generic controller error */\n CONTROLLER_ERROR: 'CONTROLLER_ERROR',\n /** Request denied due to authorization failure */\n ACCESS_DENIED: 'ACCESS_DENIED',\n /** Request validation failed (malformed input) */\n INVALID_REQUEST: 'INVALID_REQUEST',\n },\n\n /**\n * Global/cross-cutting error codes.\n * Used for validation and other cross-layer concerns.\n */\n Global: {\n /** Object/schema validation failed */\n OBJECT_VALIDATION_ERROR: 'OBJECT_VALIDATION_ERROR',\n },\n} as const;\n\n/**\n * Type representing all possible domain error codes.\n */\nexport type DomainErrorCode = (typeof ErrorCodes.Domain)[keyof typeof ErrorCodes.Domain];\n\n/**\n * Type representing all possible application error codes.\n */\nexport type AppErrorCode = (typeof ErrorCodes.App)[keyof typeof ErrorCodes.App];\n\n/**\n * Type representing all possible infrastructure error codes.\n */\nexport type InfraErrorCode = (typeof ErrorCodes.Infra)[keyof typeof ErrorCodes.Infra];\n\n/**\n * Type representing all possible presentation error codes.\n */\nexport type PresentationErrorCode =\n (typeof ErrorCodes.Presentation)[keyof typeof ErrorCodes.Presentation];\n\n/**\n * Type representing all possible global error codes.\n */\nexport type GlobalErrorCode = (typeof ErrorCodes.Global)[keyof typeof ErrorCodes.Global];\n\n/**\n * Union type of all error codes across all layers.\n *\n * Use this when you need to accept any valid error code.\n *\n * @example\n * ```typescript\n * function logError(code: ErrorCode, message: string) {\n * console.error(`[${code}] ${message}`);\n * }\n * ```\n */\nexport type ErrorCode =\n | DomainErrorCode\n | AppErrorCode\n | InfraErrorCode\n | PresentationErrorCode\n | GlobalErrorCode;\n","import { CodedError } from './coded-error.error';\nimport { ErrorCodes, type GlobalErrorCode } from './error-codes.const';\nimport type { ValidationError } from '../interfaces/types/validation-error.type';\n\n/**\n * Error thrown when object validation fails.\n *\n * Contains structured validation errors with field paths and messages,\n * making it easy to report specific validation failures to clients.\n * Thrown by all validator implementations (Zod, ArkType, TypeBox, Valibot).\n *\n * **Flow:**\n * 1. Validator throws `ObjectValidationError` with field-level errors\n * 2. Controller catches and converts to {@link InvalidRequestError}\n * 3. HTTP layer maps to 400 Bad Request with error details\n *\n * @example\n * ```typescript\n * try {\n * const dto = CreateUserDto.create(invalidData);\n * } catch (error) {\n * if (error instanceof ObjectValidationError) {\n * console.log(error.validationErrors);\n * // [\n * // { field: 'email', message: 'Invalid email format' },\n * // { field: 'age', message: 'Must be a positive number' }\n * // ]\n * }\n * }\n * ```\n */\nexport class ObjectValidationError extends CodedError {\n /**\n * Array of field-level validation errors.\n *\n * Each entry contains:\n * - `field`: Dot-notation path to the invalid field (e.g., 'user.email')\n * - `message`: Human-readable validation failure message\n */\n validationErrors: ValidationError[];\n\n /**\n * Creates a new ObjectValidationError instance.\n *\n * @param options - Error configuration\n * @param options.message - Human-readable summary message\n * @param options.code - Machine-readable error code (default: 'OBJECT_VALIDATION_ERROR')\n * @param options.cause - Optional underlying error from validation library\n * @param options.validationErrors - Array of field-level validation errors\n */\n constructor({\n message,\n code = ErrorCodes.Global.OBJECT_VALIDATION_ERROR,\n cause,\n validationErrors,\n }: {\n message: string;\n code?: GlobalErrorCode | string;\n cause?: unknown;\n validationErrors: ValidationError[];\n }) {\n super({ message, code, cause });\n this.validationErrors = validationErrors;\n }\n\n /**\n * Creates an ObjectValidationError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new ObjectValidationError instance with the cause attached\n */\n static override fromError(cause: unknown): ObjectValidationError {\n return new ObjectValidationError({\n message: cause instanceof Error ? cause.message : 'Validation failed',\n cause,\n validationErrors: [],\n });\n }\n}\n","import { CodedError } from '../../global/exceptions/coded-error.error';\nimport { ErrorCodes, type DomainErrorCode } from '../../global/exceptions/error-codes.const';\n\n/**\n * Base error class for domain layer failures.\n *\n * Domain errors represent violations of business rules, invariants,\n * or aggregate consistency. They originate from the core domain logic\n * and should be caught and handled by the application layer.\n *\n * **When to throw:**\n * - Business rule violations (e.g., \"Cannot withdraw more than balance\")\n * - Invariant violations (e.g., \"Email format invalid\")\n * - Aggregate consistency failures\n *\n * **Child classes:**\n * - {@link InvariantViolationError} - Value object or entity invariant failures\n * - {@link PartialLoadError} - Incomplete aggregate reconstitution\n *\n * @example\n * ```typescript\n * if (account.balance < amount) {\n * throw new DomainError({\n * message: 'Insufficient funds for withdrawal',\n * code: 'INSUFFICIENT_FUNDS',\n * });\n * }\n * ```\n */\nexport class DomainError extends CodedError {\n /**\n * Creates a new DomainError instance.\n *\n * @param options - Error configuration\n * @param options.message - Human-readable error description\n * @param options.code - Machine-readable error code (default: 'DOMAIN_ERROR')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.Domain.DOMAIN_ERROR,\n cause,\n }: {\n message: string;\n code?: DomainErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates a DomainError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new DomainError instance with the cause attached\n */\n static override fromError(cause: unknown): DomainError {\n return new DomainError({\n message: cause instanceof Error ? cause.message : 'Domain error',\n cause,\n });\n }\n}\n","import { CodedError } from '../../global/exceptions/coded-error.error';\nimport { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\n\n/**\n * Base error class for application layer (use case) failures.\n *\n * Use case errors represent failures in the application's business logic\n * orchestration, such as resource conflicts, missing entities, or\n * unprocessable requests. They bridge domain errors to the presentation layer.\n *\n * **When to throw:**\n * - Resource not found (e.g., \"User with ID X not found\")\n * - Conflict states (e.g., \"Email already registered\")\n * - Unprocessable business operations\n *\n * **Child classes:**\n * - {@link ConflictError} - Resource state conflicts (HTTP 409)\n * - {@link NotFoundError} - Resource not found (HTTP 404)\n * - {@link UnprocessableError} - Valid but unprocessable request (HTTP 422)\n *\n * @example\n * ```typescript\n * const user = await this.userRepo.findById(id);\n * if (!user) {\n * throw new NotFoundError({\n * message: `User with ID ${id} not found`,\n * code: 'USER_NOT_FOUND',\n * });\n * }\n * ```\n */\nexport class UseCaseError extends CodedError {\n /**\n * Creates a new UseCaseError instance.\n *\n * @param options - Error configuration\n * @param options.message - Human-readable error description\n * @param options.code - Machine-readable error code (default: 'USE_CASE_ERROR')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.USE_CASE_ERROR,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates a UseCaseError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new UseCaseError instance with the cause attached\n */\n static override fromError(cause: unknown): UseCaseError {\n return new UseCaseError({\n message: cause instanceof Error ? cause.message : 'Use case error',\n cause,\n });\n }\n}\n","import { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\nimport { UseCaseError } from './use-case.error';\n\n/**\n * Error thrown when a requested resource does not exist.\n *\n * Indicates that the entity or resource referenced by the request\n * could not be found in the system.\n *\n * **When to throw:**\n * - Entity lookup by ID returns null\n * - Referenced resource doesn't exist\n * - Parent entity for a child operation not found\n *\n * @example\n * ```typescript\n * const user = await this.userRepo.findById(userId);\n * if (!user) {\n * throw new NotFoundError({\n * message: `User with ID ${userId} not found`,\n * code: 'USER_NOT_FOUND',\n * });\n * }\n * ```\n *\n * @extends UseCaseError\n */\nexport class NotFoundError extends UseCaseError {\n /**\n * Creates a new NotFoundError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of what was not found\n * @param options.code - Machine-readable error code (default: 'NOT_FOUND')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.NOT_FOUND,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates a NotFoundError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new NotFoundError instance with the cause attached\n */\n static override fromError(cause: unknown): NotFoundError {\n return new NotFoundError({\n message: cause instanceof Error ? cause.message : 'Resource not found',\n cause,\n });\n }\n}\n","import { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\nimport { UseCaseError } from './use-case.error';\n\n/**\n * Error thrown when an operation conflicts with existing state.\n *\n * Indicates that the requested operation cannot be completed because\n * it would violate uniqueness constraints or cause state conflicts.\n *\n * **When to throw:**\n * - Duplicate unique field (e.g., email already registered)\n * - Optimistic locking conflict (stale version)\n * - Concurrent modification detected\n *\n * @example\n * ```typescript\n * const existing = await this.userRepo.findByEmail(email);\n * if (existing) {\n * throw new ConflictError({\n * message: 'Email already registered',\n * code: 'EMAIL_ALREADY_EXISTS',\n * });\n * }\n * ```\n *\n * @extends UseCaseError\n */\nexport class ConflictError extends UseCaseError {\n /**\n * Creates a new ConflictError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of the conflict\n * @param options.code - Machine-readable error code (default: 'CONFLICT')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.CONFLICT,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates a ConflictError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new ConflictError instance with the cause attached\n */\n static override fromError(cause: unknown): ConflictError {\n return new ConflictError({\n message: cause instanceof Error ? cause.message : 'Conflict error',\n cause,\n });\n }\n}\n","import { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\nimport { UseCaseError } from './use-case.error';\n\n/**\n * Error thrown when a request is valid but cannot be processed.\n *\n * The request is syntactically correct and passes validation, but\n * business logic prevents the operation from being completed.\n *\n * **When to throw:**\n * - Business rule prevents operation (e.g., insufficient balance)\n * - Invalid state transition (e.g., canceling a completed order)\n * - Preconditions not met for the operation\n *\n * @example\n * ```typescript\n * if (account.balance < amount) {\n * throw new UnprocessableError({\n * message: 'Insufficient balance for withdrawal',\n * code: 'INSUFFICIENT_BALANCE',\n * });\n * }\n * ```\n *\n * @extends UseCaseError\n */\nexport class UnprocessableError extends UseCaseError {\n /**\n * Creates a new UnprocessableError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of why the request cannot be processed\n * @param options.code - Machine-readable error code (default: 'UNPROCESSABLE')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.UNPROCESSABLE,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates an UnprocessableError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new UnprocessableError instance with the cause attached\n */\n static override fromError(cause: unknown): UnprocessableError {\n return new UnprocessableError({\n message: cause instanceof Error ? cause.message : 'Unprocessable request',\n cause,\n });\n }\n}\n","import { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\nimport { UseCaseError } from './use-case.error';\n\n/**\n * Error thrown when authorization for an operation is denied.\n *\n * Indicates that the user is authenticated but lacks permission to perform\n * the requested operation. Commonly thrown from the `authorize()` method\n * of use cases when access checks fail.\n *\n * **When to throw:**\n * - User doesn't own the resource they're trying to modify\n * - User lacks required role or permission\n * - Organization/tenant isolation violation\n * - Business rule restricts the operation for this user\n *\n * **Difference from AccessDeniedError:**\n * - `ForbiddenError` is an application layer error (use case authorization)\n * - `AccessDeniedError` is a presentation layer error (controller/guard level)\n *\n * @example Use case authorization\n * ```typescript\n * class UpdateActivityUseCase extends BaseInboundAdapter<Input, Output, AuthContext> {\n * protected async authorize(input: Input): Promise<AuthContext> {\n * const activity = await this.activityRepo.findById(input.activityId);\n * if (!activity) {\n * throw new NotFoundError({ message: 'Activity not found' });\n * }\n * if (activity.organizationId !== input.organizationId) {\n * throw new ForbiddenError({\n * message: 'Not authorized to modify this activity',\n * code: 'ACTIVITY_ACCESS_DENIED',\n * });\n * }\n * return { activity };\n * }\n * }\n * ```\n *\n * @example Role-based authorization\n * ```typescript\n * if (!user.roles.includes('admin')) {\n * throw new ForbiddenError({\n * message: 'Admin role required for this operation',\n * });\n * }\n * ```\n *\n * @extends UseCaseError\n */\nexport class ForbiddenError extends UseCaseError {\n /**\n * Creates a new ForbiddenError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of why authorization was denied\n * @param options.code - Machine-readable error code (default: 'FORBIDDEN')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.FORBIDDEN,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates a ForbiddenError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new ForbiddenError instance with the cause attached\n */\n static override fromError(cause: unknown): ForbiddenError {\n return new ForbiddenError({\n message: cause instanceof Error ? cause.message : 'Operation forbidden',\n cause,\n });\n }\n}\n","import { ErrorCodes, type AppErrorCode } from '../../global/exceptions/error-codes.const';\nimport { UseCaseError } from './use-case.error';\n\n/**\n * Error thrown when authentication is required or invalid.\n *\n * Indicates that the user is not authenticated or their authentication\n * credentials are invalid/expired. This is different from `ForbiddenError`\n * which is for authenticated users who lack permission.\n *\n * **When to throw:**\n * - User is not logged in but authentication is required\n * - Authentication token is missing, invalid, or expired\n * - Session has been invalidated\n * - API key is invalid or revoked\n *\n * **Difference from ForbiddenError:**\n * - `UnauthorizedError` (401) = Not authenticated (who are you?)\n * - `ForbiddenError` (403) = Authenticated but not authorized (you can't do this)\n *\n * @example Missing authentication\n * ```typescript\n * protected async authorize(input: Input): Promise<AuthContext> {\n * if (!input.userId) {\n * throw new UnauthorizedError({ message: 'Authentication required' });\n * }\n *\n * const user = await this.userRepo.findById(input.userId);\n * if (!user) {\n * throw new UnauthorizedError({ message: 'Invalid user credentials' });\n * }\n *\n * return { user };\n * }\n * ```\n *\n * @example Token validation\n * ```typescript\n * if (!token || isTokenExpired(token)) {\n * throw new UnauthorizedError({\n * message: 'Session expired, please log in again',\n * code: 'SESSION_EXPIRED',\n * });\n * }\n * ```\n *\n * @extends UseCaseError\n */\nexport class UnauthorizedError extends UseCaseError {\n /**\n * Creates a new UnauthorizedError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of why authentication failed\n * @param options.code - Machine-readable error code (default: 'UNAUTHORIZED')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.App.UNAUTHORIZED,\n cause,\n }: {\n message: string;\n code?: AppErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates an UnauthorizedError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new UnauthorizedError instance with the cause attached\n */\n static override fromError(cause: unknown): UnauthorizedError {\n return new UnauthorizedError({\n message: cause instanceof Error ? cause.message : 'Authentication required',\n cause,\n });\n }\n}\n","import { CodedError } from '../../global/exceptions/coded-error.error';\nimport { ErrorCodes, type InfraErrorCode } from '../../global/exceptions/error-codes.const';\n\n/**\n * Base error class for infrastructure layer failures.\n *\n * Infrastructure errors represent failures in external dependencies\n * such as databases, network services, file systems, or third-party APIs.\n * They are automatically created by {@link BaseOutboundAdapter} when\n * repository or gateway methods fail.\n *\n * **When to throw:**\n * - Database connection or query failures\n * - Network timeouts or connection errors\n * - External API failures\n * - File system errors\n *\n * **Child classes:**\n * - {@link DbError} - Database operation failures\n * - {@link NetworkError} - Network connectivity issues\n * - {@link TimeoutError} - Operation timeout\n * - {@link ExternalServiceError} - Third-party service failures\n *\n * @example\n * ```typescript\n * // In a repository extending BaseOutboundAdapter\n * protected override createInfraError(error: unknown, methodName: string): InfraError {\n * return new DbError({\n * message: `Database error in ${methodName}`,\n * cause: error,\n * });\n * }\n * ```\n */\nexport class InfraError extends CodedError {\n /**\n * Creates a new InfraError instance.\n *\n * @param options - Error configuration\n * @param options.message - Human-readable error description\n * @param options.code - Machine-readable error code (default: 'INFRA_ERROR')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.Infra.INFRA_ERROR,\n cause,\n }: {\n message: string;\n code?: InfraErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates an InfraError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new InfraError instance with the cause attached\n */\n static override fromError(cause: unknown): InfraError {\n return new InfraError({\n message: cause instanceof Error ? cause.message : 'Infrastructure error',\n cause,\n });\n }\n}\n","import { CodedError } from '../../global/exceptions/coded-error.error';\nimport { ErrorCodes, type PresentationErrorCode } from '../../global/exceptions/error-codes.const';\n\n/**\n * Error thrown when access to a resource is denied.\n *\n * Indicates that the requester does not have permission to perform\n * the requested operation. Thrown by {@link GuardedController} when\n * an access guard returns `isAllowed: false`.\n *\n * **When thrown:**\n * - Access guard denies the request\n * - User lacks required permissions\n * - Resource ownership check fails\n *\n * @example GuardedController usage\n * ```typescript\n * const controller = GuardedController.create({\n * accessGuard: (req) => ({\n * isAllowed: req.user?.role === 'admin',\n * reason: 'Admin access required',\n * }),\n * // ... other config\n * });\n * ```\n *\n * @example Manual usage\n * ```typescript\n * if (!user.canAccess(resource)) {\n * throw new AccessDeniedError({\n * message: 'You do not have access to this resource',\n * code: 'RESOURCE_ACCESS_DENIED',\n * });\n * }\n * ```\n *\n * @extends CodedError\n */\nexport class AccessDeniedError extends CodedError {\n /**\n * Creates a new AccessDeniedError instance.\n *\n * @param options - Error configuration\n * @param options.message - Description of why access was denied\n * @param options.code - Machine-readable error code (default: 'ACCESS_DENIED')\n * @param options.cause - Optional underlying error\n */\n constructor({\n message,\n code = ErrorCodes.Presentation.ACCESS_DENIED,\n cause,\n }: {\n message: string;\n code?: PresentationErrorCode | string;\n cause?: unknown;\n }) {\n super({ message, code, cause });\n }\n\n /**\n * Creates an AccessDeniedError from a caught error.\n *\n * @param cause - The original caught error\n * @returns A new AccessDeniedError instance with the cause attached\n */\n static override fromError(cause: unknown): AccessDeniedError {\n return new AccessDeniedError({\n message: cause instanceof Error ? cause.message : 'Access denied',\n cause,\n });\n }\n}\n","/**\n * @fileoverview Centralized error mapping for HTTP frameworks.\n *\n * Provides a single source of truth for mapping onion-lasagna errors\n * to HTTP status codes and response bodies.\n *\n * @module http/shared/error-mapping\n */\n\nimport { CodedError } from '../../../global/exceptions/coded-error.error';\nimport { ObjectValidationError } from '../../../global/exceptions/object-validation.error';\nimport { DomainError } from '../../../domain/exceptions/domain.error';\nimport { UseCaseError } from '../../../app/exceptions/use-case.error';\nimport { NotFoundError } from '../../../app/exceptions/not-found.error';\nimport { ConflictError } from '../../../app/exceptions/conflict.error';\nimport { UnprocessableError } from '../../../app/exceptions/unprocessable.error';\nimport { ForbiddenError } from '../../../app/exceptions/forbidden.error';\nimport { UnauthorizedError } from '../../../app/exceptions/unauthorized.error';\nimport { InfraError } from '../../../infra/exceptions/infra.error';\nimport { ControllerError } from '../../exceptions/controller.error';\nimport { AccessDeniedError } from '../../exceptions/access-denied.error';\nimport { InvalidRequestError } from '../../exceptions/invalid-request.error';\nimport type { ErrorResponseBody, MappedErrorResponse } from './types';\n\n// ============================================================================\n// Constants and Interfaces\n// ============================================================================\n\n/**\n * Default masked error response for internal errors.\n */\nconst MASKED_ERROR_BODY: ErrorResponseBody = {\n message: 'An unexpected error occurred',\n errorCode: 'INTERNAL_ERROR',\n};\n\n/**\n * Known internal error type names that should be masked.\n */\nconst INTERNAL_ERROR_TYPES = [\n 'DomainError',\n 'InfraError',\n 'ControllerError',\n 'NetworkError',\n 'PersistenceError',\n 'ExternalServiceError',\n 'InvariantViolationError',\n];\n\n/**\n * Validation error item structure.\n */\ninterface ValidationErrorInput {\n field: string;\n message: string;\n}\n\n/**\n * Validation error structure for string-based checking.\n */\ninterface ValidationErrorItem {\n field: string;\n message: string;\n}\n\n/**\n * Interface for errors with validation items.\n */\ninterface ErrorWithValidation {\n message: string;\n code: string;\n validationErrors: ValidationErrorItem[];\n}\n\n/**\n * Interface for coded errors.\n */\ninterface CodedErrorLike {\n message: string;\n code: string;\n}\n\n// ============================================================================\n// String-based type checking helpers (for bundled code compatibility)\n// ============================================================================\n\n/**\n * Checks if error matches a specific error type by checking its constructor name.\n * This approach avoids issues with multiple class instances in bundled code.\n * Handles both original names and tsup's mangled names (prefixed with _).\n *\n * @param error - The error to check\n * @param typeName - The error type name to match\n * @returns True if error matches the type name\n */\nexport function isErrorType(error: unknown, typeName: string): error is CodedErrorLike {\n if (!error || typeof error !== 'object') return false;\n // Guard against objects without constructor (e.g., Object.create(null))\n const constructor = Object.prototype.hasOwnProperty.call(error, 'constructor')\n ? (error as { constructor?: { name?: string } }).constructor\n : Object.getPrototypeOf(error)?.constructor;\n if (!constructor) return false;\n const name = constructor.name;\n // Check both the original name and the mangled name (tsup prefixes with _)\n return name === typeName || name === `_${typeName}`;\n}\n\n/**\n * Checks if error has validation errors array.\n *\n * @param error - The error to check\n * @returns True if error has validationErrors property\n */\nexport function hasValidationErrors(error: unknown): error is ErrorWithValidation {\n if (!error || typeof error !== 'object') return false;\n return (\n 'validationErrors' in error && Array.isArray((error as ErrorWithValidation).validationErrors)\n );\n}\n\n// ============================================================================\n// Response body builders\n// ============================================================================\n\n/**\n * Builds a validation error response body from error details.\n *\n * @param message - The error message\n * @param code - The error code\n * @param validationErrors - Array of field validation errors\n * @returns Error response body with errorItems\n */\nfunction buildValidationErrorBody(\n message: string,\n code: string,\n validationErrors: readonly ValidationErrorInput[],\n): ErrorResponseBody {\n return {\n message,\n errorCode: code,\n errorItems: validationErrors.map((e) => ({\n item: e.field,\n message: e.message,\n })),\n };\n}\n\n/**\n * Builds a simple error response body from error details.\n *\n * @param message - The error message\n * @param code - The error code\n * @returns Error response body\n */\nfunction buildSimpleErrorBody(message: string, code: string): ErrorResponseBody {\n return {\n message,\n errorCode: code,\n };\n}\n\n// ============================================================================\n// Primary error mapping functions (with bundled code fallback)\n// ============================================================================\n\n/**\n * Maps an error to the appropriate HTTP status code.\n * Uses instanceof first, then falls back to name-based checking for bundled code.\n *\n * @param error - The error to map\n * @returns HTTP status code\n */\nexport function getHttpStatusCode(error: unknown): number {\n // Try instanceof first (faster)\n if (error instanceof ObjectValidationError) return 400;\n if (error instanceof InvalidRequestError) return 400;\n if (error instanceof UnauthorizedError) return 401;\n if (error instanceof ForbiddenError) return 403;\n if (error instanceof AccessDeniedError) return 403;\n if (error instanceof NotFoundError) return 404;\n if (error instanceof ConflictError) return 409;\n if (error instanceof UnprocessableError) return 422;\n if (error instanceof UseCaseError) return 400;\n\n // Fall back to name-based checking for bundled code (e.g., _NotFoundError)\n if (isErrorType(error, 'ObjectValidationError')) return 400;\n if (isErrorType(error, 'InvalidRequestError')) return 400;\n if (isErrorType(error, 'UnauthorizedError')) return 401;\n if (isErrorType(error, 'ForbiddenError')) return 403;\n if (isErrorType(error, 'AccessDeniedError')) return 403;\n if (isErrorType(error, 'NotFoundError')) return 404;\n if (isErrorType(error, 'ConflictError')) return 409;\n if (isErrorType(error, 'UnprocessableError')) return 422;\n if (isErrorType(error, 'UseCaseError')) return 400;\n\n return 500;\n}\n\n/**\n * Checks if an error should have its details masked in the response.\n *\n * Security-sensitive errors (domain, infrastructure, controller) are masked\n * to prevent leaking implementation details.\n * Uses instanceof first, then falls back to name-based checking for bundled code.\n *\n * @param error - The error to check\n * @returns True if error details should be hidden\n */\nexport function shouldMaskError(error: unknown): boolean {\n // Try instanceof first (faster)\n if (\n error instanceof DomainError ||\n error instanceof InfraError ||\n error instanceof ControllerError\n ) {\n return true;\n }\n\n // Fall back to name-based checking for bundled code\n for (const errorType of INTERNAL_ERROR_TYPES) {\n if (isErrorType(error, errorType)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Creates the response body for an error.\n * Uses instanceof first, then falls back to name-based checking for bundled code.\n *\n * @param error - The error to create body for\n * @returns Error response body\n */\nexport function createErrorResponseBody(error: unknown): ErrorResponseBody {\n // Masked errors - hide internal details\n if (shouldMaskError(error)) {\n return MASKED_ERROR_BODY;\n }\n\n // Validation errors - include field details (try instanceof first)\n if (error instanceof ObjectValidationError) {\n return buildValidationErrorBody(error.message, error.code, error.validationErrors);\n }\n if (error instanceof InvalidRequestError) {\n return buildValidationErrorBody(error.message, error.code, error.validationErrors);\n }\n\n // Validation errors - fall back to name-based checking for bundled code\n if (isErrorType(error, 'ObjectValidationError') && hasValidationErrors(error)) {\n return buildValidationErrorBody(error.message, error.code, error.validationErrors);\n }\n if (isErrorType(error, 'InvalidRequestError') && hasValidationErrors(error)) {\n return buildValidationErrorBody(error.message, error.code, error.validationErrors);\n }\n\n // Other coded errors - expose message and code (try instanceof first)\n if (error instanceof CodedError) {\n return buildSimpleErrorBody(error.message, error.code);\n }\n\n // Other coded errors - fall back to name-based checking\n if (isErrorType(error, 'CodedError')) {\n return buildSimpleErrorBody(error.message, error.code);\n }\n\n // Check for any error with message and code properties\n if (\n error &&\n typeof error === 'object' &&\n 'message' in error &&\n 'code' in error &&\n typeof (error as CodedErrorLike).message === 'string' &&\n typeof (error as CodedErrorLike).code === 'string'\n ) {\n return buildSimpleErrorBody((error as CodedErrorLike).message, (error as CodedErrorLike).code);\n }\n\n // Unknown errors - mask\n return MASKED_ERROR_BODY;\n}\n\n/**\n * Maps an error to a complete HTTP response structure.\n *\n * Mapping strategy (checked in order):\n * 1. `ObjectValidationError` / `InvalidRequestError` → 400 Bad Request (with field errors)\n * 2. `UseCaseError` → 400 Bad Request\n * 3. `UnauthorizedError` → 401 Unauthorized\n * 4. `ForbiddenError` / `AccessDeniedError` → 403 Forbidden\n * 5. `NotFoundError` → 404 Not Found\n * 6. `ConflictError` → 409 Conflict\n * 7. `UnprocessableError` → 422 Unprocessable Entity\n * 8. `DomainError` / `InfraError` / `ControllerError` → 500 Internal Server Error (masked)\n * 9. Unknown → 500 Internal Server Error (masked)\n *\n * @param error - The error to map\n * @returns Mapped error response with status and body\n */\nexport function mapErrorToHttpResponse(error: unknown): MappedErrorResponse {\n return {\n status: getHttpStatusCode(error),\n body: createErrorResponseBody(error),\n };\n}\n","/**\n * @fileoverview Centralized error mapping for GraphQL resolvers.\n *\n * Maps onion-lasagna errors to GraphQL error extensions,\n * following the same pattern as the HTTP error mapper.\n *\n * @module graphql/shared/error-mapping\n */\n\nimport { CodedError } from '../../../global/exceptions/coded-error.error';\nimport { ObjectValidationError } from '../../../global/exceptions/object-validation.error';\nimport { DomainError } from '../../../domain/exceptions/domain.error';\nimport { UseCaseError } from '../../../app/exceptions/use-case.error';\nimport { NotFoundError } from '../../../app/exceptions/not-found.error';\nimport { ConflictError } from '../../../app/exceptions/conflict.error';\nimport { UnprocessableError } from '../../../app/exceptions/unprocessable.error';\nimport { ForbiddenError } from '../../../app/exceptions/forbidden.error';\nimport { UnauthorizedError } from '../../../app/exceptions/unauthorized.error';\nimport { InfraError } from '../../../infra/exceptions/infra.error';\nimport { AccessDeniedError } from '../../exceptions/access-denied.error';\nimport { isErrorType, hasValidationErrors } from '../../http/shared/error-mapping';\nimport type { GraphQLErrorCode, MappedGraphQLError, GraphQLValidationErrorItem } from './types';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Default masked error for internal errors.\n */\nconst MASKED_ERROR: MappedGraphQLError = {\n message: 'An unexpected error occurred',\n extensions: { code: 'INTERNAL_ERROR' },\n};\n\n/**\n * Known internal error type names that should be masked.\n */\nconst INTERNAL_ERROR_TYPES = [\n 'DomainError',\n 'InfraError',\n 'ControllerError',\n 'NetworkError',\n 'PersistenceError',\n 'ExternalServiceError',\n 'InvariantViolationError',\n];\n\n// ============================================================================\n// Extension Code Mapping\n// ============================================================================\n\n/**\n * Gets the GraphQL extension code for an error.\n * Uses instanceof first, then falls back to name-based checking for bundled code.\n */\nexport function getGraphQLErrorCode(error: unknown): GraphQLErrorCode {\n // Try instanceof first (faster)\n if (error instanceof ObjectValidationError) return 'VALIDATION_ERROR';\n if (error instanceof UnauthorizedError) return 'FORBIDDEN';\n if (error instanceof ForbiddenError) return 'FORBIDDEN';\n if (error instanceof AccessDeniedError) return 'FORBIDDEN';\n if (error instanceof NotFoundError) return 'NOT_FOUND';\n if (error instanceof ConflictError) return 'CONFLICT';\n if (error instanceof UnprocessableError) return 'UNPROCESSABLE';\n if (error instanceof UseCaseError) return 'BAD_REQUEST';\n\n // Fall back to name-based checking for bundled code\n if (isErrorType(error, 'ObjectValidationError')) return 'VALIDATION_ERROR';\n if (isErrorType(error, 'UnauthorizedError')) return 'FORBIDDEN';\n if (isErrorType(error, 'ForbiddenError')) return 'FORBIDDEN';\n if (isErrorType(error, 'AccessDeniedError')) return 'FORBIDDEN';\n if (isErrorType(error, 'NotFoundError')) return 'NOT_FOUND';\n if (isErrorType(error, 'ConflictError')) return 'CONFLICT';\n if (isErrorType(error, 'UnprocessableError')) return 'UNPROCESSABLE';\n if (isErrorType(error, 'UseCaseError')) return 'BAD_REQUEST';\n\n return 'INTERNAL_ERROR';\n}\n\n/**\n * Checks if an error should have its details masked.\n *\n * Security-sensitive errors (domain, infrastructure) are masked\n * to prevent leaking implementation details.\n */\nexport function shouldMaskGraphQLError(error: unknown): boolean {\n // Try instanceof first (faster)\n if (error instanceof DomainError || error instanceof InfraError) {\n return true;\n }\n\n // Fall back to name-based checking for bundled code\n for (const errorType of INTERNAL_ERROR_TYPES) {\n if (isErrorType(error, errorType)) {\n return true;\n }\n }\n\n return false;\n}\n\n// ============================================================================\n// Primary Mapping Function\n// ============================================================================\n\n/**\n * Maps an error to a GraphQL error with extensions.\n *\n * Mapping strategy (checked in order):\n * 1. `ObjectValidationError` → `VALIDATION_ERROR` (with field errors)\n * 2. `UnauthorizedError` / `ForbiddenError` / `AccessDeniedError` → `FORBIDDEN`\n * 3. `NotFoundError` → `NOT_FOUND`\n * 4. `ConflictError` → `CONFLICT`\n * 5. `UnprocessableError` → `UNPROCESSABLE`\n * 6. `UseCaseError` → `BAD_REQUEST`\n * 7. `DomainError` / `InfraError` → `INTERNAL_ERROR` (masked)\n * 8. Unknown → `INTERNAL_ERROR` (masked)\n *\n * @param error - The error to map\n * @returns Mapped GraphQL error with message and extensions\n */\nexport function mapErrorToGraphQLError(error: unknown): MappedGraphQLError {\n // Masked errors - hide internal details\n if (shouldMaskGraphQLError(error)) {\n return MASKED_ERROR;\n }\n\n const code = getGraphQLErrorCode(error);\n\n // Validation errors - include field details\n if (error instanceof ObjectValidationError) {\n return buildValidationError(error.message, code, error.code, error.validationErrors);\n }\n\n // Validation errors - fall back to name-based checking for bundled code\n if (isErrorType(error, 'ObjectValidationError') && hasValidationErrors(error)) {\n return buildValidationError(error.message, code, error.code, error.validationErrors);\n }\n\n // Other coded errors - expose message\n if (error instanceof CodedError) {\n return {\n message: error.message,\n extensions: { code, originalCode: error.code },\n };\n }\n\n // Other coded errors - fall back to name-based checking\n if (isErrorType(error, 'CodedError')) {\n return {\n message: error.message,\n extensions: { code, originalCode: error.code },\n };\n }\n\n // Check for any error with message and code properties\n if (\n error &&\n typeof error === 'object' &&\n 'message' in error &&\n 'code' in error &&\n typeof (error as { message: string }).message === 'string' &&\n typeof (error as { code: string }).code === 'string'\n ) {\n return {\n message: (error as { message: string }).message,\n extensions: { code, originalCode: (error as { code: string }).code },\n };\n }\n\n // Unknown errors - mask\n return MASKED_ERROR;\n}\n\n/**\n * Builds a validation error response with field details.\n */\nfunction buildValidationError(\n message: string,\n code: GraphQLErrorCode,\n originalCode: string,\n validationErrors: readonly { field: string; message: string }[],\n): MappedGraphQLError {\n return {\n message,\n extensions: {\n code,\n originalCode,\n validationErrors: validationErrors.map(\n (e): GraphQLValidationErrorItem => ({\n field: e.field,\n message: e.message,\n }),\n ),\n },\n };\n}\n","/**\n * @fileoverview Server types for the GraphQL field system.\n *\n * @module graphql/server/types\n */\n\nimport type { GraphQLFieldDefinition, GraphQLOperationType } from '../field/types';\n\n// Re-export UseCasePort from HTTP — same interface, no duplication\nexport type { UseCasePort } from '../../http/server/types';\n\n// ============================================================================\n// Validated Args\n// ============================================================================\n\n/**\n * Validated arguments with typed data.\n * This is what handlers receive after input validation passes.\n */\nexport interface ValidatedArgs<TField extends GraphQLFieldDefinition> {\n /** Validated input arguments. */\n readonly input: TField['_types']['input'];\n\n /** Raw unvalidated arguments for advanced use cases. */\n readonly raw: unknown;\n}\n\n/**\n * Typed GraphQL context based on field definition.\n * If the field defines a context schema, this will be the validated type.\n * Otherwise, it falls back to the generic GraphQLHandlerContext.\n */\nexport type TypedGraphQLContext<TField extends GraphQLFieldDefinition> =\n TField['_types']['context'] extends undefined\n ? GraphQLHandlerContext\n : TField['_types']['context'];\n\n// ============================================================================\n// Handler Context\n// ============================================================================\n\n/**\n * Context passed to GraphQL handlers.\n * Can be extended with custom context via graphqlRoutes options.\n */\nexport interface GraphQLHandlerContext {\n /** Request ID for tracing. */\n readonly requestId?: string;\n\n /** Additional context data. */\n readonly [key: string]: unknown;\n}\n\n// ============================================================================\n// Handler Types\n// ============================================================================\n\n/**\n * Handler configuration using the use case pattern.\n *\n * @typeParam TField - The field definition type\n * @typeParam TInput - Use case input type\n * @typeParam TOutput - Use case output type\n */\nexport interface GraphQLHandlerConfig<\n TField extends GraphQLFieldDefinition,\n TInput = void,\n TOutput = void,\n> {\n /**\n * Maps the validated args to use case input.\n * Both `args` and `ctx` are fully typed based on field schemas.\n */\n readonly argsMapper: (args: ValidatedArgs<TField>, ctx: TypedGraphQLContext<TField>) => TInput;\n\n /** The use case to execute. */\n readonly useCase: { execute(input?: TInput): Promise<TOutput> };\n\n /**\n * Maps the use case output to the GraphQL response.\n */\n readonly responseMapper: (output: TOutput) => TField['_types']['output'];\n\n /** Middleware to run before the handler. */\n readonly middleware?: readonly GraphQLMiddlewareFunction[];\n}\n\n/**\n * Simple handler function that directly returns the output.\n * Use this for query and mutation fields.\n */\nexport type SimpleGraphQLHandlerFn<TField extends GraphQLFieldDefinition> = (\n args: ValidatedArgs<TField>,\n ctx: TypedGraphQLContext<TField>,\n) => Promise<TField['_types']['output']> | TField['_types']['output'];\n\n/**\n * Subscription handler function that returns an async iterable.\n * Each yielded value is sent to the subscriber.\n */\nexport type SimpleGraphQLSubscriptionFn<TField extends GraphQLFieldDefinition> = (\n args: ValidatedArgs<TField>,\n ctx: TypedGraphQLContext<TField>,\n) => AsyncIterable<TField['_types']['output']>;\n\n/**\n * Configuration for a simple handler (no use case).\n */\nexport interface SimpleGraphQLHandlerConfig<TField extends GraphQLFieldDefinition> {\n readonly handler: SimpleGraphQLHandlerFn<TField>;\n readonly middleware?: readonly GraphQLMiddlewareFunction[];\n}\n\n/**\n * Union of all handler config types.\n * Used internally to store handlers in the builder.\n */\nexport type AnyGraphQLHandlerConfig<\n TField extends GraphQLFieldDefinition,\n TInput = unknown,\n TOutput = unknown,\n> = GraphQLHandlerConfig<TField, TInput, TOutput> | SimpleGraphQLHandlerConfig<TField>;\n\n/**\n * Type guard to check if config is a simple GraphQL handler.\n */\nexport function isSimpleGraphQLHandlerConfig(\n config: AnyGraphQLHandlerConfig<GraphQLFieldDefinition, unknown, unknown>,\n): config is SimpleGraphQLHandlerConfig<GraphQLFieldDefinition> {\n return 'handler' in config && typeof config.handler === 'function';\n}\n\n/**\n * GraphQL middleware function type.\n */\nexport type GraphQLMiddlewareFunction = (\n args: unknown,\n context: GraphQLHandlerContext,\n next: () => Promise<unknown>,\n) => Promise<unknown>;\n\n// ============================================================================\n// Server Configuration\n// ============================================================================\n\n/**\n * Options for creating GraphQL routes.\n */\nexport interface CreateGraphQLRoutesOptions {\n /** Global middleware to run before all handlers. */\n readonly middleware?: readonly GraphQLMiddlewareFunction[];\n\n /**\n * Whether to validate incoming args against field schemas.\n * When enabled, invalid args throw ObjectValidationError.\n * @default true\n */\n readonly validateInput?: boolean;\n\n /**\n * Whether to validate outgoing results against field schemas.\n * When enabled, invalid results log a warning.\n * @default true\n */\n readonly validateOutput?: boolean;\n\n /**\n * Context factory to create handler context.\n */\n readonly createContext?: (rawContext: unknown) => GraphQLHandlerContext;\n\n /**\n * Allow partial handler configuration (not all fields need handlers).\n * When true, missing handlers are silently skipped.\n * When false (default), missing handlers throw an error.\n * @default false\n * @internal Used by builder pattern's buildPartial()\n */\n readonly allowPartial?: boolean;\n}\n\n// ============================================================================\n// Unified GraphQL Field (for framework adapters)\n// ============================================================================\n\n/**\n * GraphQL field input compatible with framework adapters.\n * This is the output of graphqlRoutes().build().\n */\nexport interface UnifiedGraphQLField {\n /** Schema key path (e.g., 'users.get'). */\n readonly key: string;\n\n /** GraphQL operation type. */\n readonly operation: GraphQLOperationType;\n\n /** Handler function. */\n readonly handler: (args: unknown, context: unknown) => Promise<unknown>;\n\n /** Field metadata for documentation. */\n readonly metadata: {\n readonly fieldId?: string;\n readonly description?: string;\n readonly tags?: readonly string[];\n readonly deprecated?: boolean;\n readonly deprecationReason?: string;\n };\n}\n","/**\n * @fileoverview Internal implementation for creating GraphQL routes with auto-validation.\n *\n * Generates GraphQL field handlers from a schema definition.\n * Each handler automatically validates incoming args and outgoing results\n * against the field's schemas.\n *\n * @module graphql/server/create-graphql-routes\n * @internal\n */\n\nimport type { SchemaAdapter, ValidationIssue } from '../../http/schema/types';\nimport type {\n GraphQLSchemaConfig,\n GraphQLSchemaDefinition,\n GraphQLFieldDefinition,\n} from '../field/types';\nimport { isSchemaDefinition, collectFields } from '../field/types';\nimport { generateFieldId } from '../field/utils';\nimport { mapErrorToGraphQLError } from '../shared/error-mapping';\nimport type {\n AnyGraphQLHandlerConfig,\n CreateGraphQLRoutesOptions,\n GraphQLHandlerContext,\n UnifiedGraphQLField,\n ValidatedArgs,\n} from './types';\nimport { isSimpleGraphQLHandlerConfig } from './types';\nimport { ObjectValidationError } from '../../../global/exceptions/object-validation.error';\nimport { UnauthorizedError } from '../../../app/exceptions/unauthorized.error';\n\n/**\n * Internal implementation for creating GraphQL routes.\n * Used by the builder pattern (graphqlRoutes).\n *\n * @internal\n */\nexport function createGraphQLRoutesInternal<T extends GraphQLSchemaConfig>(\n schema: T | GraphQLSchemaDefinition<T>,\n handlers: Record<string, AnyGraphQLHandlerConfig<GraphQLFieldDefinition, unknown, unknown>>,\n options?: CreateGraphQLRoutesOptions,\n): UnifiedGraphQLField[] {\n const config = isSchemaDefinition(schema) ? schema.fields : schema;\n const collectedFields = collectFields(config);\n\n const result: UnifiedGraphQLField[] = [];\n\n const resolvedOptions: CreateGraphQLRoutesOptions = {\n ...options,\n validateInput: options?.validateInput ?? true,\n validateOutput: options?.validateOutput ?? true,\n allowPartial: options?.allowPartial ?? false,\n };\n\n for (const { key, field } of collectedFields) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handlerConfig = handlers[key] as\n | AnyGraphQLHandlerConfig<GraphQLFieldDefinition, any, any>\n | undefined;\n\n if (!handlerConfig) {\n if (resolvedOptions.allowPartial) {\n continue;\n }\n throw new Error(\n `Missing handler for field \"${key}\". All fields must have a handler configuration.`,\n );\n }\n\n result.push(createFieldHandler(key, field, handlerConfig, resolvedOptions));\n }\n\n return result;\n}\n\n/**\n * Creates a single field handler with validation and error mapping.\n */\nfunction createFieldHandler(\n key: string,\n field: GraphQLFieldDefinition,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: AnyGraphQLHandlerConfig<GraphQLFieldDefinition, any, any>,\n options: CreateGraphQLRoutesOptions,\n): UnifiedGraphQLField {\n const middleware = config.middleware ?? [];\n const globalMiddleware = options?.middleware ?? [];\n const allMiddleware = [...globalMiddleware, ...middleware];\n const shouldValidateInput = options.validateInput ?? true;\n const shouldValidateOutput = options.validateOutput ?? true;\n\n return {\n key,\n operation: field.operation,\n metadata: {\n fieldId: generateFieldId(key),\n description: field.docs.description,\n tags: field.docs.tags as string[],\n deprecated: field.docs.deprecated,\n deprecationReason: field.docs.deprecationReason,\n },\n handler: async (rawArgs: unknown, rawContext: unknown): Promise<unknown> => {\n // Create context\n const context: GraphQLHandlerContext = options?.createContext\n ? options.createContext(rawContext)\n : ((rawContext as GraphQLHandlerContext) ?? { requestId: generateRequestId() });\n\n // Validate context (if schema defined)\n // Context validation failures → UnauthorizedError (401 semantics).\n // Error message is generic to prevent leaking context schema details\n // (field names, types, constraints) to unauthenticated clients.\n let validatedContext: unknown = context;\n if (field.context) {\n const contextResult = validateContextData(field, context);\n if (!contextResult.success) {\n throw new UnauthorizedError({\n message: 'Authentication required',\n });\n }\n validatedContext = contextResult.data;\n }\n\n // Validate input args (if enabled and schema defined)\n let validatedInput: unknown = rawArgs;\n if (shouldValidateInput && field.input) {\n const inputResult = validateInputData(field, rawArgs);\n if (!inputResult.success) {\n const errors = inputResult.errors ?? [];\n throw new ObjectValidationError({\n message: 'Input validation failed',\n validationErrors: errors.map((e) => ({\n field: e.path.join('.'),\n message: e.message,\n })),\n });\n }\n validatedInput = inputResult.data;\n }\n\n const validatedArgs: ValidatedArgsInternal = {\n input: validatedInput,\n raw: rawArgs,\n };\n\n // Execute the pipeline\n const executePipeline = async (): Promise<unknown> => {\n if (isSimpleGraphQLHandlerConfig(config)) {\n return config.handler(\n validatedArgs as unknown as ValidatedArgs<GraphQLFieldDefinition>,\n validatedContext as GraphQLHandlerContext,\n );\n } else {\n const { argsMapper, useCase, responseMapper } = config;\n\n const input = argsMapper(\n validatedArgs as unknown as ValidatedArgs<GraphQLFieldDefinition>,\n validatedContext as GraphQLHandlerContext,\n );\n\n const output = await useCase.execute(input);\n\n return responseMapper(output);\n }\n };\n\n let result: unknown;\n\n if (allMiddleware.length === 0) {\n result = await executePipeline();\n } else {\n // Build middleware chain with re-entrancy guard\n let index = 0;\n let called = false;\n const next = async (): Promise<unknown> => {\n if (index >= allMiddleware.length) {\n if (called) throw new Error('next() called after pipeline already executed');\n called = true;\n return executePipeline();\n }\n const currentIndex = index++;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- index bounds checked above\n const mw = allMiddleware[currentIndex]!;\n return mw(rawArgs, context, next);\n };\n\n result = await next();\n }\n\n // Validate output (if enabled and schema defined)\n if (shouldValidateOutput && field.output) {\n const outputResult = validateOutputData(field, result);\n if (!outputResult.success) {\n const details = outputResult.errors\n ?.map((e) => `${e.path.join('.')}: ${e.message}`)\n .join('; ');\n throw new ObjectValidationError({\n message: `Output validation failed for field \"${key}\": ${details}`,\n validationErrors: (outputResult.errors ?? []).map((e) => ({\n field: e.path.join('.'),\n message: e.message,\n })),\n });\n }\n }\n\n return result;\n },\n };\n}\n\n// ============================================================================\n// Validation Helpers\n// ============================================================================\n\ninterface ValidationResultInternal {\n success: boolean;\n errors?: ValidationIssue[];\n data?: unknown;\n}\n\n/**\n * Validates input args against the field's input schema.\n */\nfunction validateInputData(field: GraphQLFieldDefinition, args: unknown): ValidationResultInternal {\n const schema = field.input as SchemaAdapter | undefined;\n if (!schema) return { success: true, data: args };\n\n const result = schema.validate(args);\n if (result.success) {\n return { success: true, data: result.data };\n }\n\n const errors = result.issues.map((issue) => ({\n ...issue,\n path: ['input', ...issue.path],\n }));\n\n return { success: false, errors };\n}\n\n/**\n * Validates output data against the field's output schema.\n */\nfunction validateOutputData(\n field: GraphQLFieldDefinition,\n data: unknown,\n): ValidationResultInternal {\n const schema = field.output as SchemaAdapter | undefined;\n if (!schema) return { success: true, data };\n\n const result = schema.validate(data);\n if (result.success) {\n return { success: true, data: result.data };\n }\n\n const errors = result.issues.map((issue) => ({\n ...issue,\n path: ['output', ...issue.path],\n }));\n\n return { success: false, errors };\n}\n\n/**\n * Validates context data against the field's context schema.\n */\nfunction validateContextData(\n field: GraphQLFieldDefinition,\n context: GraphQLHandlerContext,\n): ValidationResultInternal {\n const schema = field.context as SchemaAdapter | undefined;\n if (!schema) return { success: true, data: context };\n\n const result = schema.validate(context);\n if (result.success) {\n return { success: true, data: result.data };\n }\n\n const errors = result.issues.map((issue) => ({\n ...issue,\n path: ['context', ...issue.path],\n }));\n\n return { success: false, errors };\n}\n\n/**\n * Internal validated args type with unknown fields.\n * Used inside createFieldHandler where specific types are erased.\n */\ninterface ValidatedArgsInternal {\n readonly input: unknown;\n readonly raw: unknown;\n}\n\n/**\n * Generates a unique request ID.\n */\nfunction generateRequestId(): string {\n return `gql_${crypto.randomUUID()}`;\n}\n","/**\n * @fileoverview Builder pattern for creating type-safe GraphQL routes.\n *\n * The `graphqlRoutes` function returns a builder that provides 100% type inference\n * for all handler parameters — no manual type annotations required.\n *\n * @module graphql/server/graphql-routes-builder\n */\n\nimport type {\n GraphQLSchemaConfig,\n GraphQLSchemaDefinition,\n GetField,\n SchemaKeys,\n GraphQLFieldDefinition,\n} from '../field/types';\nimport type {\n AnyGraphQLHandlerConfig,\n CreateGraphQLRoutesOptions,\n GraphQLHandlerConfig,\n GraphQLMiddlewareFunction,\n SimpleGraphQLHandlerConfig,\n SimpleGraphQLHandlerFn,\n TypedGraphQLContext,\n UnifiedGraphQLField,\n ValidatedArgs,\n} from './types';\nimport { createGraphQLRoutesInternal } from './create-graphql-routes';\n\n// ============================================================================\n// Builder Types\n// ============================================================================\n\n/**\n * Error type displayed when attempting to build() with missing handlers.\n * The `___missingFields` property shows which fields are missing.\n */\nexport interface MissingHandlersError<TMissing extends string> {\n /**\n * This error indicates that not all GraphQL fields have handlers.\n * Use buildPartial() to build with only the defined handlers,\n * or add handlers for the missing fields.\n */\n (options?: never): never;\n /** Fields that are missing handlers. */\n readonly ___missingFields: TMissing;\n}\n\n/**\n * Handler configuration for the builder pattern.\n */\nexport interface BuilderGraphQLHandlerConfig<\n TField extends GraphQLFieldDefinition,\n TInput,\n TOutput,\n> {\n /**\n * Maps the validated args to use case input.\n * Both `args` and `ctx` are fully typed based on field schemas.\n */\n readonly argsMapper: (args: ValidatedArgs<TField>, ctx: TypedGraphQLContext<TField>) => TInput;\n\n /** The use case to execute. */\n readonly useCase: { execute(input?: TInput): Promise<TOutput> };\n\n /**\n * Maps the use case output to the GraphQL response.\n */\n readonly responseMapper: (output: TOutput) => TField['_types']['output'];\n\n /** Middleware to run before the handler. */\n readonly middleware?: readonly GraphQLMiddlewareFunction[];\n}\n\n/**\n * Builder interface for creating type-safe GraphQL routes.\n *\n * Each `.handle()` call captures the specific field type and provides\n * full type inference for argsMapper, useCase, and responseMapper.\n *\n * @typeParam T - The schema configuration type\n * @typeParam THandled - Union of field keys that have handlers (accumulates)\n *\n * @example\n * ```typescript\n * const fields = graphqlRoutes(projectSchema)\n * .handleWithUseCase('projects.create', {\n * argsMapper: (args, ctx) => ({\n * name: args.input.name,\n * createdBy: ctx.userId,\n * }),\n * useCase: createProjectUseCase,\n * responseMapper: (output) => ({ projectId: output.projectId }),\n * })\n * .handle('projects.list', async (args) => {\n * return allProjects;\n * })\n * .build();\n * ```\n */\nexport interface GraphQLRoutesBuilder<\n T extends GraphQLSchemaConfig,\n THandled extends string = never,\n> {\n /**\n * Register a simple handler for a field.\n * The handler receives validated args and context, returns output directly.\n */\n handle<K extends Exclude<SchemaKeys<T>, THandled>>(\n key: K,\n handlerOrConfig:\n | SimpleGraphQLHandlerFn<GetField<T, K>>\n | SimpleGraphQLHandlerConfig<GetField<T, K>>,\n ): GraphQLRoutesBuilder<T, THandled | K>;\n\n /**\n * Register a handler using the use case pattern.\n * Follows: argsMapper → useCase.execute() → responseMapper\n */\n handleWithUseCase<K extends Exclude<SchemaKeys<T>, THandled>, TInput, TOutput>(\n key: K,\n config: BuilderGraphQLHandlerConfig<GetField<T, K>, TInput, TOutput>,\n ): GraphQLRoutesBuilder<T, THandled | K>;\n\n /**\n * Build the fields array for framework adapter registration.\n *\n * This method is only available when ALL fields have handlers.\n * If some fields are missing handlers, use `buildPartial()` instead.\n */\n build: [Exclude<SchemaKeys<T>, THandled>] extends [never]\n ? (options?: CreateGraphQLRoutesOptions) => UnifiedGraphQLField[]\n : MissingHandlersError<Exclude<SchemaKeys<T>, THandled>>;\n\n /**\n * Build fields for only the defined handlers.\n * No compile-time enforcement of completeness.\n */\n buildPartial(options?: CreateGraphQLRoutesOptions): UnifiedGraphQLField[];\n}\n\n// ============================================================================\n// Builder Implementation\n// ============================================================================\n\n/**\n * Internal builder implementation.\n *\n * Uses an immutable pattern where each handle() call returns a new\n * builder instance with the updated handlers map.\n */\nclass GraphQLRoutesBuilderImpl<T extends GraphQLSchemaConfig, THandled extends string = never> {\n private readonly schema: T | GraphQLSchemaDefinition<T>;\n private readonly handlers: Map<\n string,\n AnyGraphQLHandlerConfig<GraphQLFieldDefinition, unknown, unknown>\n >;\n\n constructor(\n schema: T | GraphQLSchemaDefinition<T>,\n handlers?: Map<string, AnyGraphQLHandlerConfig<GraphQLFieldDefinition, unknown, unknown>>,\n ) {\n this.schema = schema;\n this.handlers = handlers ?? new Map();\n }\n\n handle<K extends Exclude<SchemaKeys<T>, THandled>>(\n key: K,\n handlerOrConfig:\n | SimpleGraphQLHandlerFn<GetField<T, K>>\n | SimpleGraphQLHandlerConfig<GetField<T, K>>,\n ): GraphQLRoutesBuilder<T, THandled | K> {\n // Cast through unknown is safe: type erasure in the builder requires this cast\n // The type system tracks the specific field types through the interface\n const config: SimpleGraphQLHandlerConfig<GraphQLFieldDefinition> =\n typeof handlerOrConfig === 'function'\n ? { handler: handlerOrConfig as unknown as SimpleGraphQLHandlerFn<GraphQLFieldDefinition> }\n : (handlerOrConfig as unknown as SimpleGraphQLHandlerConfig<GraphQLFieldDefinition>);\n\n const newHandlers = new Map(this.handlers);\n newHandlers.set(key as string, config);\n\n return new GraphQLRoutesBuilderImpl<T, THandled | K>(\n this.schema,\n newHandlers,\n ) as unknown as GraphQLRoutesBuilder<T, THandled | K>;\n }\n\n handleWithUseCase<K extends Exclude<SchemaKeys<T>, THandled>, TInput, TOutput>(\n key: K,\n config: BuilderGraphQLHandlerConfig<GetField<T, K>, TInput, TOutput>,\n ): GraphQLRoutesBuilder<T, THandled | K> {\n const newHandlers = new Map(this.handlers);\n // Cast through unknown is safe: the type system tracks THandled | K through the interface\n newHandlers.set(\n key as string,\n config as unknown as GraphQLHandlerConfig<GraphQLFieldDefinition, unknown, unknown>,\n );\n\n return new GraphQLRoutesBuilderImpl<T, THandled | K>(\n this.schema,\n newHandlers,\n ) as unknown as GraphQLRoutesBuilder<T, THandled | K>;\n }\n\n build(options?: CreateGraphQLRoutesOptions): UnifiedGraphQLField[] {\n return createGraphQLRoutesInternal(this.schema, Object.fromEntries(this.handlers), options);\n }\n\n buildPartial(options?: CreateGraphQLRoutesOptions): UnifiedGraphQLField[] {\n return createGraphQLRoutesInternal(this.schema, Object.fromEntries(this.handlers), {\n ...options,\n allowPartial: true,\n });\n }\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Creates a type-safe GraphQL routes builder for a schema.\n *\n * The builder pattern provides 100% type inference for all handler parameters:\n * - `args.input` is typed from the field's input schema\n * - `ctx` is typed from the field's context schema (or GraphQLHandlerContext)\n * - `output` in responseMapper is typed from the use case\n *\n * @param schema - GraphQL schema definition or schema config\n * @returns Builder for registering handlers\n *\n * @example Basic usage\n * ```typescript\n * import { graphqlRoutes } from '@cosmneo/onion-lasagna/graphql/server';\n * import { projectSchema } from './schema';\n *\n * const fields = graphqlRoutes(projectSchema)\n * .handleWithUseCase('projects.create', {\n * argsMapper: (args, ctx) => ({\n * name: args.input.name,\n * createdBy: ctx.userId,\n * }),\n * useCase: createProjectUseCase,\n * responseMapper: (output) => ({ projectId: output.projectId }),\n * })\n * .handle('projects.list', async () => allProjects)\n * .build();\n * ```\n */\nexport function graphqlRoutes<T extends GraphQLSchemaConfig>(\n schema: T | GraphQLSchemaDefinition<T>,\n): GraphQLRoutesBuilder<T, never> {\n return new GraphQLRoutesBuilderImpl(schema) as unknown as GraphQLRoutesBuilder<T, never>;\n}\n","/**\n * @fileoverview GraphQL SDL generation from schema definitions.\n *\n * The `generateGraphQLSDL` function creates a complete GraphQL Schema\n * Definition Language string from a schema definition.\n *\n * Input/output schemas are converted to JSON Schema via `toJsonSchema()`,\n * then mapped to GraphQL type definitions.\n *\n * @module graphql/sdl/generate\n */\n\nimport type { SchemaAdapter, JsonSchema } from '../../http/schema/types';\nimport type {\n GraphQLSchemaConfig,\n GraphQLSchemaDefinition,\n GraphQLFieldDefinition,\n} from '../field/types';\nimport { isSchemaDefinition, collectFields } from '../field/types';\nimport { generateFieldId } from '../field/utils';\nimport type { GraphQLSDLConfig } from './types';\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Generates a GraphQL SDL string from a schema definition.\n *\n * Walks the schema structure, extracts JSON schemas from all field\n * definitions, and builds a complete SDL with Query, Mutation, and\n * type definitions.\n *\n * @param schema - Schema definition or schema config\n * @param config - Optional SDL generation configuration\n * @returns Complete GraphQL SDL string\n *\n * @example Basic usage\n * ```typescript\n * import { generateGraphQLSDL } from '@cosmneo/onion-lasagna/graphql/sdl';\n *\n * const sdl = generateGraphQLSDL(projectSchema, {\n * preamble: 'scalar DateTime',\n * });\n *\n * console.log(sdl);\n * // type Query {\n * // projectsGet(input: ProjectsGetInput!): ProjectsGetOutput\n * // projectsList: ProjectsListOutput\n * // }\n * // ...\n * ```\n */\nexport function generateGraphQLSDL<T extends GraphQLSchemaConfig>(\n schema: T | GraphQLSchemaDefinition<T>,\n config?: GraphQLSDLConfig,\n): string {\n const fields = isSchemaDefinition(schema) ? schema.fields : schema;\n const collectedFields = collectFields(fields);\n\n const includeDescriptions = config?.includeDescriptions ?? true;\n const includeDeprecations = config?.includeDeprecations ?? true;\n\n // Partition fields by operation type\n const queries: { fieldId: string; field: GraphQLFieldDefinition }[] = [];\n const mutations: { fieldId: string; field: GraphQLFieldDefinition }[] = [];\n const subscriptions: { fieldId: string; field: GraphQLFieldDefinition }[] = [];\n\n for (const { key, field } of collectedFields) {\n const fieldId = generateFieldId(key);\n if (field.operation === 'query') {\n queries.push({ fieldId, field });\n } else if (field.operation === 'mutation') {\n mutations.push({ fieldId, field });\n } else if (field.operation === 'subscription') {\n subscriptions.push({ fieldId, field });\n }\n }\n\n // Collect all named types that need to be emitted\n const namedTypes: Map<string, string> = new Map();\n const lines: string[] = [];\n\n // Preamble\n if (config?.preamble) {\n lines.push(config.preamble);\n lines.push('');\n }\n\n // Build Query type\n if (queries.length > 0) {\n lines.push('type Query {');\n for (const { fieldId, field } of queries) {\n const fieldLine = buildFieldLine(\n fieldId,\n field,\n namedTypes,\n includeDescriptions,\n includeDeprecations,\n );\n lines.push(fieldLine);\n }\n lines.push('}');\n lines.push('');\n }\n\n // Build Mutation type\n if (mutations.length > 0) {\n lines.push('type Mutation {');\n for (const { fieldId, field } of mutations) {\n const fieldLine = buildFieldLine(\n fieldId,\n field,\n namedTypes,\n includeDescriptions,\n includeDeprecations,\n );\n lines.push(fieldLine);\n }\n lines.push('}');\n lines.push('');\n }\n\n // Build Subscription type\n if (subscriptions.length > 0) {\n lines.push('type Subscription {');\n for (const { fieldId, field } of subscriptions) {\n const fieldLine = buildFieldLine(\n fieldId,\n field,\n namedTypes,\n includeDescriptions,\n includeDeprecations,\n );\n lines.push(fieldLine);\n }\n lines.push('}');\n lines.push('');\n }\n\n // Emit named types (inputs and outputs)\n for (const [, typeBody] of namedTypes) {\n lines.push(typeBody);\n lines.push('');\n }\n\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\n// ============================================================================\n// Internal Helpers\n// ============================================================================\n\n/**\n * Builds a single field line for a root type (Query/Mutation/Subscription).\n */\nfunction buildFieldLine(\n fieldId: string,\n field: GraphQLFieldDefinition,\n namedTypes: Map<string, string>,\n includeDescriptions: boolean,\n includeDeprecations: boolean,\n): string {\n const parts: string[] = [];\n\n // Description as SDL doc string (escaped to prevent triple-quote injection)\n if (includeDescriptions && field.docs.description) {\n const escaped = field.docs.description.replace(/\"\"\"/g, '\\\\\"\"\"');\n parts.push(` \"\"\"${escaped}\"\"\"`);\n }\n\n // Build args and return type\n const inputTypeName = field.input ? `${capitalize(fieldId)}Input` : undefined;\n const outputTypeName = field.output ? `${capitalize(fieldId)}Output` : undefined;\n\n // Register named input type\n if (field.input && inputTypeName) {\n const jsonSchema = (field.input as SchemaAdapter).toJsonSchema();\n namedTypes.set(inputTypeName, buildInputType(inputTypeName, jsonSchema));\n }\n\n // Register named output type\n if (field.output && outputTypeName) {\n const jsonSchema = (field.output as SchemaAdapter).toJsonSchema();\n namedTypes.set(outputTypeName, buildOutputType(outputTypeName, jsonSchema));\n }\n\n // Build field signature\n let signature = ` ${fieldId}`;\n\n if (inputTypeName) {\n signature += `(input: ${inputTypeName}!)`;\n }\n\n signature += ': ';\n signature += outputTypeName ?? 'JSON';\n\n // Deprecation directive\n if (includeDeprecations && field.docs.deprecated) {\n const reason = field.docs.deprecationReason;\n signature += reason ? ` @deprecated(reason: \"${escapeSDLString(reason)}\")` : ' @deprecated';\n }\n\n if (parts.length > 0) {\n return parts.join('\\n') + '\\n' + signature;\n }\n return signature;\n}\n\n/**\n * Builds a GraphQL input type from a JSON schema.\n */\nfunction buildInputType(typeName: string, jsonSchema: JsonSchema): string {\n const lines: string[] = [`input ${typeName} {`];\n\n if (jsonSchema.properties && typeof jsonSchema.properties === 'object') {\n const required = new Set(\n Array.isArray(jsonSchema.required) ? (jsonSchema.required as string[]) : [],\n );\n\n for (const [propName, propSchema] of Object.entries(\n jsonSchema.properties as Record<string, JsonSchema>,\n )) {\n const graphqlType = jsonSchemaToGraphQLType(propSchema);\n const isRequired = required.has(propName);\n lines.push(` ${propName}: ${graphqlType}${isRequired ? '!' : ''}`);\n }\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\n/**\n * Builds a GraphQL output type from a JSON schema.\n */\nfunction buildOutputType(typeName: string, jsonSchema: JsonSchema): string {\n const lines: string[] = [`type ${typeName} {`];\n\n if (jsonSchema.properties && typeof jsonSchema.properties === 'object') {\n const required = new Set(\n Array.isArray(jsonSchema.required) ? (jsonSchema.required as string[]) : [],\n );\n\n for (const [propName, propSchema] of Object.entries(\n jsonSchema.properties as Record<string, JsonSchema>,\n )) {\n const graphqlType = jsonSchemaToGraphQLType(propSchema);\n const isRequired = required.has(propName);\n lines.push(` ${propName}: ${graphqlType}${isRequired ? '!' : ''}`);\n }\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n\n/**\n * Converts a JSON schema to a GraphQL type string.\n */\nfunction jsonSchemaToGraphQLType(schema: JsonSchema): string {\n if (!schema || typeof schema !== 'object') return 'JSON';\n\n // Handle enum\n if (schema.enum && Array.isArray(schema.enum)) {\n return 'String';\n }\n\n // Handle type\n const type = schema.type as string | undefined;\n\n switch (type) {\n case 'string':\n return 'String';\n case 'integer':\n return 'Int';\n case 'number':\n return 'Float';\n case 'boolean':\n return 'Boolean';\n case 'array': {\n const items = schema.items as JsonSchema | undefined;\n if (items) {\n return `[${jsonSchemaToGraphQLType(items)}]`;\n }\n return '[JSON]';\n }\n case 'object':\n return 'JSON';\n default:\n // Handle oneOf, anyOf, allOf — fallback to JSON\n if (schema.oneOf || schema.anyOf || schema.allOf) {\n return 'JSON';\n }\n // Object without explicit type but has properties\n if (schema.properties) {\n return 'JSON';\n }\n return 'JSON';\n }\n}\n\n/**\n * Capitalizes the first letter of a string.\n */\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Escapes a string for use in SDL quoted string literals.\n * Handles backslashes, quotes, newlines, and triple-quote injection.\n */\nfunction escapeSDLString(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2EA,SAAS,sBAMP,WACA,OAMA;AACA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA,OAAO,MAAM,SAAS;AAAA,IACtB,QAAQ,MAAM,UAAU;AAAA,IACxB,SAAS,MAAM,WAAW;AAAA,IAC1B,MAAM;AAAA,MACJ,SAAS,MAAM,MAAM;AAAA,MACrB,aAAa,MAAM,MAAM;AAAA,MACzB,MAAM,MAAM,MAAM;AAAA,MAClB,YAAY,MAAM,MAAM,cAAc;AAAA,MACtC,mBAAmB,MAAM,MAAM;AAAA,IACjC;AAAA,IACA,iBAAiB;AAAA,IACjB,QAAQ;AAAA,EACV;AAEA,SAAO,OAAO,OAAO,UAAU;AAMjC;AAqBO,SAAS,YAKd,SAAsD,CAAC,GAMvD;AACA,SAAO,sBAAsB,SAAS,MAAM;AAC9C;AAkBO,SAAS,eAKd,SAAsD,CAAC,GAMvD;AACA,SAAO,sBAAsB,YAAY,MAAM;AACjD;AAoBO,SAAS,mBAK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7C,WAAO;AAAA,EACT;AAGA,QAAM,OAAO,OAAO;AAEpB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK,SAAS;AACZ,YAAM,QAAQ,OAAO;AACrB,UAAI,OAAO;AACT,eAAO,IAAI,wBAAwB,KAAK,CAAC;AAAA,MAC3C;AACA,aAAO;AAAA,IACT;AAAA,IACA,KAAK;AACH,aAAO;AAAA,IACT;AAEE,UAAI,OAAO,SAAS,OAAO,SAAS,OAAO,OAAO;AAChD,eAAO;AAAA,MACT;AAEA,UAAI,OAAO,YAAY;AACrB,eAAO;AAAA,MACT;AACA,aAAO;AAAA,EACX;AACF;AAKA,SAAS,WAAW,KAAqB;AACvC,SAAO,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAClD;AAMA,SAAS,gBAAgB,KAAqB;AAC5C,SAAO,IACJ,QAAQ,OAAO,MAAM,EACrB,QAAQ,MAAM,KAAK,EACnB,QAAQ,OAAO,KAAK,EACpB,QAAQ,OAAO,KAAK,EACpB,QAAQ,OAAO,KAAK;AACzB;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DefineGraphQLSchemaOptions, defineGraphQLSchema, defineMutation, defineQuery, defineSubscription, generateFieldId, mergeGraphQLSchemas } from './field/index.cjs';
|
|
2
|
+
export { D as DeepMergeSchemas, h as DeepMergeSchemasAll, F as FlattenSchema, g as GetField, b as GraphQLFieldDefinition, a as GraphQLFieldDocumentation, G as GraphQLOperationType, d as GraphQLSchemaConfig, e as GraphQLSchemaDefaults, f as GraphQLSchemaDefinition, c as GraphQLSchemaEntry, k as InferFieldContext, i as InferFieldInput, I as InferFieldOperation, j as InferFieldOutput, S as SchemaKeys, n as collectFields, l as isFieldDefinition, m as isSchemaDefinition } from '../schema-definition.type-C9PntBVc.cjs';
|
|
3
|
+
export { BuilderGraphQLHandlerConfig, CreateGraphQLRoutesOptions, GraphQLHandlerConfig, GraphQLHandlerContext, GraphQLMiddlewareFunction, GraphQLRoutesBuilder, MissingHandlersError, SimpleGraphQLHandlerConfig, SimpleGraphQLHandlerFn, TypedGraphQLContext, UnifiedGraphQLField, ValidatedArgs, graphqlRoutes, isSimpleGraphQLHandlerConfig } from './server/index.cjs';
|
|
4
|
+
export { GraphQLSDLConfig, generateGraphQLSDL } from './sdl/index.cjs';
|
|
5
|
+
export { GraphQLErrorCode, GraphQLErrorExtensions, GraphQLValidationErrorItem, MappedGraphQLError, getGraphQLErrorCode, mapErrorToGraphQLError, shouldMaskGraphQLError } from './shared/index.cjs';
|
|
6
|
+
export { U as UseCasePort } from '../types-afYpL7Ap.cjs';
|
|
7
|
+
import '../http/schema/types.cjs';
|
|
8
|
+
import '../router-definition.type-BElX-Pl4.cjs';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DefineGraphQLSchemaOptions, defineGraphQLSchema, defineMutation, defineQuery, defineSubscription, generateFieldId, mergeGraphQLSchemas } from './field/index.js';
|
|
2
|
+
export { D as DeepMergeSchemas, h as DeepMergeSchemasAll, F as FlattenSchema, g as GetField, b as GraphQLFieldDefinition, a as GraphQLFieldDocumentation, G as GraphQLOperationType, d as GraphQLSchemaConfig, e as GraphQLSchemaDefaults, f as GraphQLSchemaDefinition, c as GraphQLSchemaEntry, k as InferFieldContext, i as InferFieldInput, I as InferFieldOperation, j as InferFieldOutput, S as SchemaKeys, n as collectFields, l as isFieldDefinition, m as isSchemaDefinition } from '../schema-definition.type-CuhQLDr0.js';
|
|
3
|
+
export { BuilderGraphQLHandlerConfig, CreateGraphQLRoutesOptions, GraphQLHandlerConfig, GraphQLHandlerContext, GraphQLMiddlewareFunction, GraphQLRoutesBuilder, MissingHandlersError, SimpleGraphQLHandlerConfig, SimpleGraphQLHandlerFn, TypedGraphQLContext, UnifiedGraphQLField, ValidatedArgs, graphqlRoutes, isSimpleGraphQLHandlerConfig } from './server/index.js';
|
|
4
|
+
export { GraphQLSDLConfig, generateGraphQLSDL } from './sdl/index.js';
|
|
5
|
+
export { GraphQLErrorCode, GraphQLErrorExtensions, GraphQLValidationErrorItem, MappedGraphQLError, getGraphQLErrorCode, mapErrorToGraphQLError, shouldMaskGraphQLError } from './shared/index.js';
|
|
6
|
+
export { U as UseCasePort } from '../types-B6Q1iCgf.js';
|
|
7
|
+
import '../http/schema/types.js';
|
|
8
|
+
import '../router-definition.type-DxG8ncJZ.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "../chunk-NQMFWI6Q.js";
|
|
2
|
+
import {
|
|
3
|
+
defineGraphQLSchema,
|
|
4
|
+
defineMutation,
|
|
5
|
+
defineQuery,
|
|
6
|
+
defineSubscription,
|
|
7
|
+
mergeGraphQLSchemas
|
|
8
|
+
} from "../chunk-TZRBETT3.js";
|
|
9
|
+
import {
|
|
10
|
+
graphqlRoutes,
|
|
11
|
+
isSimpleGraphQLHandlerConfig
|
|
12
|
+
} from "../chunk-ANLXZHUS.js";
|
|
13
|
+
import "../chunk-FEY2GSVT.js";
|
|
14
|
+
import {
|
|
15
|
+
getGraphQLErrorCode,
|
|
16
|
+
mapErrorToGraphQLError,
|
|
17
|
+
shouldMaskGraphQLError
|
|
18
|
+
} from "../chunk-VBG3UYQR.js";
|
|
19
|
+
import {
|
|
20
|
+
generateGraphQLSDL
|
|
21
|
+
} from "../chunk-4RFWJ5XZ.js";
|
|
22
|
+
import {
|
|
23
|
+
collectFields,
|
|
24
|
+
generateFieldId,
|
|
25
|
+
isFieldDefinition,
|
|
26
|
+
isSchemaDefinition
|
|
27
|
+
} from "../chunk-BG2FY27M.js";
|
|
28
|
+
import "../chunk-HNEAH6OZ.js";
|
|
29
|
+
import "../chunk-T7S574XQ.js";
|
|
30
|
+
import "../chunk-3BY5RBF2.js";
|
|
31
|
+
import "../chunk-A4JUAZK4.js";
|
|
32
|
+
export {
|
|
33
|
+
collectFields,
|
|
34
|
+
defineGraphQLSchema,
|
|
35
|
+
defineMutation,
|
|
36
|
+
defineQuery,
|
|
37
|
+
defineSubscription,
|
|
38
|
+
generateFieldId,
|
|
39
|
+
generateGraphQLSDL,
|
|
40
|
+
getGraphQLErrorCode,
|
|
41
|
+
graphqlRoutes,
|
|
42
|
+
isFieldDefinition,
|
|
43
|
+
isSchemaDefinition,
|
|
44
|
+
isSimpleGraphQLHandlerConfig,
|
|
45
|
+
mapErrorToGraphQLError,
|
|
46
|
+
mergeGraphQLSchemas,
|
|
47
|
+
shouldMaskGraphQLError
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|