import { i as BuilderArtifact, l as BuilderArtifactOperation, s as BuilderArtifactFragment, t as BuilderService, w as BuilderError } from "./service-LY6CaxEG.cjs"; import { CanonicalId } from "@soda-gql/common"; import { ResolvedSodaGqlConfig } from "@soda-gql/config"; //#region packages/builder/src/plugin/errors.d.ts type OptionsInvalidBuilderConfig = { readonly code: "INVALID_BUILDER_CONFIG"; readonly message: string; }; type OptionsMissingBuilderConfig = { readonly code: "MISSING_BUILDER_CONFIG"; readonly message: string; }; type OptionsConfigLoadFailed = { readonly code: "CONFIG_LOAD_FAILED"; readonly message: string; }; type BuilderEntryNotFound = Extract; type BuilderDocDuplicate = Extract; type BuilderCircularDependency = Extract; type BuilderModuleEvaluationFailed = Extract; type BuilderWriteFailed = Extract; type AnalysisMetadataMissingCause = { readonly filename: string; }; type AnalysisArtifactMissingCause = { readonly filename: string; readonly canonicalId: CanonicalId; }; type AnalysisUnsupportedArtifactTypeCause = { readonly filename: string; readonly canonicalId: CanonicalId; readonly artifactType: string; }; type PluginErrorBase = { readonly type: "PluginError"; readonly code: Code; readonly message: string; readonly cause: Cause; }; type PluginOptionsInvalidBuilderConfigError = PluginErrorBase<"OPTIONS_INVALID_BUILDER_CONFIG", OptionsInvalidBuilderConfig | OptionsMissingBuilderConfig | OptionsConfigLoadFailed> & { readonly stage: "normalize-options"; }; type PluginBuilderEntryNotFoundError = PluginErrorBase<"SODA_GQL_BUILDER_ENTRY_NOT_FOUND", BuilderEntryNotFound> & { readonly stage: "builder"; readonly entry: string; }; type PluginBuilderDocDuplicateError = PluginErrorBase<"SODA_GQL_BUILDER_DOC_DUPLICATE", BuilderDocDuplicate> & { readonly stage: "builder"; readonly name: string; readonly sources: readonly string[]; }; type PluginBuilderCircularDependencyError = PluginErrorBase<"SODA_GQL_BUILDER_CIRCULAR_DEPENDENCY", BuilderCircularDependency> & { readonly stage: "builder"; readonly chain: readonly string[]; }; type PluginBuilderModuleEvaluationFailedError = PluginErrorBase<"SODA_GQL_BUILDER_MODULE_EVALUATION_FAILED", BuilderModuleEvaluationFailed> & { readonly stage: "builder"; readonly filePath: string; readonly astPath: string; }; type PluginBuilderWriteFailedError = PluginErrorBase<"SODA_GQL_BUILDER_WRITE_FAILED", BuilderWriteFailed> & { readonly stage: "builder"; readonly outPath: string; }; type PluginBuilderUnexpectedError = PluginErrorBase<"SODA_GQL_BUILDER_UNEXPECTED", unknown> & { readonly stage: "builder"; }; type PluginAnalysisMetadataMissingError = PluginErrorBase<"SODA_GQL_METADATA_NOT_FOUND", AnalysisMetadataMissingCause> & { readonly stage: "analysis"; readonly filename: string; }; type PluginAnalysisArtifactMissingError = PluginErrorBase<"SODA_GQL_ANALYSIS_ARTIFACT_NOT_FOUND", AnalysisArtifactMissingCause> & { readonly stage: "analysis"; readonly filename: string; readonly canonicalId: CanonicalId; }; type PluginAnalysisUnsupportedArtifactTypeError = PluginErrorBase<"SODA_GQL_UNSUPPORTED_ARTIFACT_TYPE", AnalysisUnsupportedArtifactTypeCause> & { readonly stage: "analysis"; readonly filename: string; readonly canonicalId: CanonicalId; readonly artifactType: string; }; type TransformMissingBuilderArgCause = { readonly filename: string; readonly builderType: string; readonly argName: string; }; type TransformUnsupportedValueTypeCause = { readonly valueType: string; }; type TransformAstVisitorFailedCause = { readonly filename: string; readonly reason: string; }; type PluginTransformMissingBuilderArgError = PluginErrorBase<"SODA_GQL_TRANSFORM_MISSING_BUILDER_ARG", TransformMissingBuilderArgCause> & { readonly stage: "transform"; readonly filename: string; readonly builderType: string; readonly argName: string; }; type PluginTransformUnsupportedValueTypeError = PluginErrorBase<"SODA_GQL_TRANSFORM_UNSUPPORTED_VALUE_TYPE", TransformUnsupportedValueTypeCause> & { readonly stage: "transform"; readonly valueType: string; }; type PluginTransformAstVisitorFailedError = PluginErrorBase<"SODA_GQL_TRANSFORM_AST_VISITOR_FAILED", TransformAstVisitorFailedCause> & { readonly stage: "transform"; readonly filename: string; readonly reason: string; }; /** * Union of all plugin error types. */ type PluginError = PluginOptionsInvalidBuilderConfigError | PluginBuilderEntryNotFoundError | PluginBuilderDocDuplicateError | PluginBuilderCircularDependencyError | PluginBuilderModuleEvaluationFailedError | PluginBuilderWriteFailedError | PluginBuilderUnexpectedError | PluginAnalysisMetadataMissingError | PluginAnalysisArtifactMissingError | PluginAnalysisUnsupportedArtifactTypeError | PluginTransformMissingBuilderArgError | PluginTransformUnsupportedValueTypeError | PluginTransformAstVisitorFailedError; /** * Format a PluginError into a human-readable message. */ declare const formatPluginError: (error: PluginError) => string; /** * Type guard for PluginError. */ declare const isPluginError: (value: unknown) => value is PluginError; /** * Assertion helper for unreachable code paths. * This is the ONLY acceptable throw in plugin code. */ declare const assertUnreachable: (value: never, context?: string) => never; //#endregion //#region packages/builder/src/plugin/session.d.ts /** * Plugin options shared across all plugins. */ type PluginOptions = { readonly configPath?: string; readonly enabled?: boolean; /** * Whether to fail the build on error. * When true (default), throws an error that fails the bundler build. * When false, logs the error and continues (graceful degradation). */ readonly failOnError?: boolean; }; /** * Plugin session containing builder service and configuration. */ type PluginSession = { readonly config: ResolvedSodaGqlConfig; readonly getArtifact: () => BuilderArtifact | null; readonly getArtifactAsync: () => Promise; /** * Whether the session is using a pre-built artifact. * When true, artifacts are loaded from a file instead of built dynamically. */ readonly isPrebuiltMode: boolean; }; /** * Create plugin session by loading config and creating cached builder service. * Returns null if disabled or config load fails. * * @param options - Plugin options * @param pluginName - Name of the plugin for error messages * @throws Error if failOnError is true and config load fails */ declare const createPluginSession: (options: PluginOptions, pluginName: string) => PluginSession | null; //#endregion //#region packages/builder/src/plugin/shared-state.d.ts /** * Transformer type for code transformation. * - 'babel': Use Babel plugin (default, wider compatibility) * - 'swc': Use SWC transformer (faster, requires @soda-gql/swc) */ type TransformerType = "babel" | "swc"; /** * Minimal interface for SWC transformer. * Matches the Transformer interface from @soda-gql/swc. */ interface SwcTransformerInterface { transform(input: { sourceCode: string; sourcePath: string; inputSourceMap?: string; }): { transformed: boolean; sourceCode: string; sourceMap?: string; errors: ReadonlyArray<{ readonly code: string; readonly message: string; readonly stage: string; }>; }; } /** * Shared state between bundler plugins and loaders. * Enables efficient artifact sharing across build pipeline stages. */ type SharedState = { pluginSession: PluginSession | null; currentArtifact: BuilderArtifact | null; moduleAdjacency: Map>; generation: number; swcTransformer: SwcTransformerInterface | null; transformerType: TransformerType | null; builderService: BuilderService | null; }; /** * Get shared state for a given project (identified by config path or cwd). */ declare const getSharedState: (key: string) => SharedState; /** * Update shared artifact. */ declare const setSharedArtifact: (key: string, artifact: BuilderArtifact | null, moduleAdjacency?: Map>) => void; /** * Get shared artifact. */ declare const getSharedArtifact: (key: string) => BuilderArtifact | null; /** * Get shared plugin session. */ declare const getSharedPluginSession: (key: string) => PluginSession | null; /** * Set shared plugin session. */ declare const setSharedPluginSession: (key: string, session: PluginSession | null) => void; /** * Get the state key from config path or cwd. */ declare const getStateKey: (configPath?: string) => string; /** * Set shared SWC transformer. */ declare const setSharedSwcTransformer: (key: string, transformer: SwcTransformerInterface | null) => void; /** * Get shared SWC transformer. */ declare const getSharedSwcTransformer: (key: string) => SwcTransformerInterface | null; /** * Set shared transformer type. */ declare const setSharedTransformerType: (key: string, transformerType: TransformerType | null) => void; /** * Get shared transformer type. */ declare const getSharedTransformerType: (key: string) => TransformerType | null; /** * Get shared BuilderService. */ declare const getSharedBuilderService: (key: string) => BuilderService | null; /** * Set shared BuilderService. */ declare const setSharedBuilderService: (key: string, service: BuilderService | null) => void; //#endregion //#region packages/builder/src/plugin/types/gql-call.d.ts /** * Base interface for all GraphQL call types. */ interface GqlCallBase { readonly canonicalId: CanonicalId; } /** * GraphQL fragment call. */ interface GqlCallFragment extends GqlCallBase { readonly type: "fragment"; readonly artifact: BuilderArtifactFragment; } /** * GraphQL operation call. */ interface GqlCallOperation extends GqlCallBase { readonly type: "operation"; readonly artifact: BuilderArtifactOperation; } /** * Union of all GraphQL call types. */ type GqlCall = GqlCallFragment | GqlCallOperation; //#endregion //#region packages/builder/src/plugin/types/metadata.d.ts /** * Unified metadata types used across all plugins. */ /** * Metadata for a GraphQL definition. */ type GqlDefinitionMetadata = { readonly astPath: string; readonly isTopLevel: boolean; readonly isExported: boolean; readonly exportBinding?: string; }; //#endregion //#region packages/builder/src/plugin/utils/canonical-id.d.ts /** * Options for resolving a canonical ID. */ type ResolveCanonicalIdOptions = { /** * Base directory for relative path computation. * When provided, the canonical ID will use a path relative to this directory. */ readonly baseDir?: string; }; /** * Resolve a canonical ID from a filename and AST path. * * @param filename - The source file path (absolute or relative) * @param astPath - The AST path within the file * @param options - Optional settings including baseDir for relative paths * @returns A canonical ID in the format `{path}::{astPath}` */ declare const resolveCanonicalId: (filename: string, astPath: string, options?: ResolveCanonicalIdOptions) => CanonicalId; //#endregion export { type GqlCall, type GqlCallBase, type GqlCallFragment, type GqlCallOperation, type GqlDefinitionMetadata, PluginAnalysisArtifactMissingError, PluginAnalysisMetadataMissingError, PluginAnalysisUnsupportedArtifactTypeError, PluginBuilderCircularDependencyError, PluginBuilderDocDuplicateError, PluginBuilderEntryNotFoundError, PluginBuilderModuleEvaluationFailedError, PluginBuilderUnexpectedError, PluginBuilderWriteFailedError, PluginError, PluginOptions, PluginOptionsInvalidBuilderConfigError, PluginSession, PluginTransformAstVisitorFailedError, PluginTransformMissingBuilderArgError, PluginTransformUnsupportedValueTypeError, ResolveCanonicalIdOptions, SharedState, SwcTransformerInterface, TransformerType, assertUnreachable, createPluginSession, formatPluginError, getSharedArtifact, getSharedBuilderService, getSharedPluginSession, getSharedState, getSharedSwcTransformer, getSharedTransformerType, getStateKey, isPluginError, resolveCanonicalId, setSharedArtifact, setSharedBuilderService, setSharedPluginSession, setSharedSwcTransformer, setSharedTransformerType }; //# sourceMappingURL=plugin-support.d.cts.map