UNPKG

@netlify/content-engine

Version:
577 lines 16.6 kB
import { IProgram, Stage } from "../commands/types"; import { GraphQLFieldExtensionDefinition } from "../schema/extensions"; import { DocumentNode, GraphQLSchema, DefinitionNode, SourceLocation } from "graphql"; import { SchemaComposer } from "graphql-compose"; import { IGatsbyCLIState } from "../reporter/redux/types"; import { ThunkAction } from "redux-thunk"; import { InternalJob, JobResultInterface } from "../utils/jobs/manager"; import { ITypeMetadata } from "../schema/infer/inference-metadata"; import { Span } from "opentracing"; type SystemPath = string; type Identifier = string; export declare enum ProgramStatus { BOOTSTRAP_FINISHED = "BOOTSTRAP_FINISHED" } export interface IGatsbyConfig { plugins?: Array<{ resolve: string; options: { [key: string]: unknown; }; }>; siteMetadata?: { title?: string; author?: string; description?: string; siteUrl?: string; [key: string]: unknown; }; polyfill?: boolean; developMiddleware?: any; proxy?: any; assetPrefix?: string; mapping?: Record<string, string>; jsxRuntime?: "classic" | "automatic"; jsxImportSource?: string; } export interface IGatsbyNode { id: Identifier; parent: Identifier; children: Array<Identifier>; internal: { type: string; counter: number; owner: string; contentDigest: string; mediaType?: string; content?: string; description?: string; }; [key: string]: unknown; fields: Array<string>; } export interface IGatsbyPlugin { id: Identifier; name: string; version: string; [key: string]: any; } export interface IGatsbyPluginContext { [key: string]: (...args: Array<any>) => any; } export interface IDefinitionMeta { name: string; def: DefinitionNode; filePath: string; text: string; templateLoc: SourceLocation; printedAst: string | null; isHook: boolean; isStaticQuery: boolean; isFragment: boolean; isConfigQuery: boolean; hash: number; } type GatsbyNodes = Map<string, IGatsbyNode>; export interface IGatsbyIncompleteJobV2 { job: InternalJob; } export interface IGatsbyIncompleteJob { job: InternalJob; plugin: IGatsbyPlugin; } export interface IGatsbyCompleteJobV2 { result: JobResultInterface; inputPaths: InternalJob["inputPaths"]; } export interface IPlugin { name: string; options: Record<string, unknown>; } export interface IBabelStage { plugins: Array<IPlugin>; presets: Array<IPlugin>; options?: { cacheDirectory: boolean; sourceType: string; sourceMaps?: string; }; } export interface IStateProgram extends IProgram { extensions: Array<string>; } export interface IQueryState { dirty: number; running: number; } export type GatsbyNodeAPI = "onPreBoostrap" | "onPostBoostrap" | "onCreateNode" | "sourceNodes" | "onPostBuild"; export interface IGatsbyState { program: IStateProgram; nodes: GatsbyNodes; nodesByType: Map<string, GatsbyNodes>; resolvedNodesCache: Map<string, any>; nodesTouched: Set<string>; typeOwners: { pluginsToTypes: Map<IGatsbyPlugin[`name`], Set<IGatsbyNode[`internal`][`type`]>>; typesToPlugins: Map<IGatsbyNode[`internal`][`type`], IGatsbyPlugin[`name`]>; }; requestHeaders: Map<string, { [header: string]: string; }>; statefulSourcePlugins: Set<string>; telemetry: ITelemetry; lastAction: ActionsUnion; flattenedPlugins: Array<{ resolve: SystemPath; id: Identifier; name: string; version: string; pluginOptions: { plugins: []; [key: string]: unknown; }; nodeAPIs: Array<GatsbyNodeAPI>; pluginFilepath: SystemPath; subPluginPaths?: Array<string>; modulePath?: string; }>; config: IGatsbyConfig; schema: GraphQLSchema; definitions: Map<string, IDefinitionMeta>; status: { plugins: Record<string, IGatsbyPlugin>; PLUGINS_HASH: Identifier; LAST_NODE_COUNTER: number; }; jobs: { active: Array<any>; done: Array<any>; }; jobsV2: { incomplete: Map<Identifier, IGatsbyIncompleteJobV2>; complete: Map<Identifier, IGatsbyCompleteJobV2>; jobsByRequest: Map<string, Set<Identifier>>; }; schemaCustomization: { composer: null | SchemaComposer<any>; context: Record<string, any>; fieldExtensions: GraphQLFieldExtensionDefinition; printConfig: { path?: string; include?: { types?: Array<string>; plugins?: Array<string>; }; exclude?: { types?: Array<string>; plugins?: Array<string>; }; withFieldTypes?: boolean; } | null; thirdPartySchemas: Array<GraphQLSchema>; types: Array<string | { typeOrTypeDef: DocumentNode; plugin: IGatsbyPlugin; }>; }; logs: IGatsbyCLIState; inferenceMetadata: { step: string; typeMap: { [key: string]: ITypeMetadata; }; }; } export type GatsbyStateKeys = keyof IGatsbyState; export interface ICachedReduxState { nodes?: IGatsbyState["nodes"]; typeOwners?: IGatsbyState["typeOwners"]; statefulSourcePlugins?: IGatsbyState["statefulSourcePlugins"]; status: IGatsbyState["status"]; jobsV2: IGatsbyState["jobsV2"]; schemaCustomization?: string | { types?: IGatsbyState["schemaCustomization"]["types"]; }; } export type ActionsUnion = IAddChildNodeToParentNodeAction | IAddFieldToNodeAction | IAddThirdPartySchema | IApiFinishedAction | ICreateFieldExtension | ICreateNodeAction | ICreatePageDependencyAction | ICreateTypes | IDeleteCacheAction | IDeleteNodeAction | IPageQueryRunAction | IPrintTypeDefinitions | IQueryClearDirtyQueriesListToEmitViaWebsocket | IQueryExtractedAction | IQueryExtractedBabelSuccessAction | IQueryExtractionBabelErrorAction | IQueryExtractionGraphQLErrorAction | IQueryStartAction | IReplaceComponentQueryAction | IReplaceStaticQueryAction | ISetPluginStatusAction | ISetProgramStatusAction | ISetResolvedNodesAction | ISetSchemaAction | ISetGraphQLDefinitionsAction | ISetSiteFlattenedPluginsAction | ITouchNodeAction | IUpdatePluginsHashAction | ICreateJobV2Action | IEndJobV2Action | IRemoveStaleJobV2Action | ISetBabelPluginAction | ISetBabelPresetAction | ISetBabelOptionsAction | ICreateJobAction | ISetJobAction | IEndJobAction | ICreateResolverContext | IClearSchemaCustomizationAction | ISetSchemaComposerAction | IStartIncrementalInferenceAction | IBuildTypeMetadataAction | IDisableTypeInferenceAction | ISetProgramAction | ISetProgramExtensions | ISetSiteConfig | ISetComponentFeatures | ISetJobV2Context | IClearJobV2Context | ISetDomainRequestHeaders | IEnableStatefulSourcePluginAction | IProcessGatsbyImageSourceUrlAction | IClearGatsbyImageSourceUrlAction; export interface ISetComponentFeatures { type: `SET_COMPONENT_FEATURES`; payload: { componentPath: string; serverData: boolean; config: boolean; Head: boolean; }; } export interface IApiFinishedAction { type: `API_FINISHED`; payload: { apiName: GatsbyNodeAPI; }; } interface ISetBabelPluginAction { type: `SET_BABEL_PLUGIN`; payload: { stage: Stage; name: IPlugin["name"]; options: IPlugin["options"]; }; } interface ISetBabelPresetAction { type: `SET_BABEL_PRESET`; payload: { stage: Stage; name: IPlugin["name"]; options: IPlugin["options"]; }; } interface ISetBabelOptionsAction { type: `SET_BABEL_OPTIONS`; payload: { stage: Stage; name: IPlugin["name"]; options: IPlugin["options"]; }; } export interface ICreateJobV2Action { type: `CREATE_JOB_V2`; payload: { job: IGatsbyIncompleteJobV2["job"]; }; plugin: { name: string; }; } export interface IEndJobV2Action { type: `END_JOB_V2`; payload: { jobContentDigest: string; result: JobResultInterface; }; plugin: { name: string; }; } export interface IRemoveStaleJobV2Action { type: `REMOVE_STALE_JOB_V2`; payload: { contentDigest: string; }; } export type ICreateJobV2FromInternalAction = ThunkAction<Promise<Record<string, unknown>>, IGatsbyState, void, ActionsUnion>; interface ICreateJobAction { type: `CREATE_JOB`; payload: { id: string; job: IGatsbyIncompleteJob["job"]; }; plugin: IGatsbyIncompleteJob["plugin"]; } interface ISetJobAction { type: `SET_JOB`; payload: { id: string; job: IGatsbyIncompleteJob["job"]; }; plugin: IGatsbyIncompleteJob["plugin"]; } interface IEndJobAction { type: `END_JOB`; payload: { id: string; job: IGatsbyIncompleteJob["job"]; }; plugin: IGatsbyIncompleteJob["plugin"]; } export interface ICreatePageDependencyActionPayloadType { path: string; nodeId?: string; connection?: string; } export interface ICreatePageDependencyAction { type: `CREATE_COMPONENT_DEPENDENCY`; plugin?: string; payload: Array<ICreatePageDependencyActionPayloadType>; } export interface IDeleteComponentDependenciesAction { type: "DELETE_COMPONENTS_DEPENDENCIES"; payload: { paths: Array<string>; }; } export interface IReplaceComponentQueryAction { type: "REPLACE_COMPONENT_QUERY"; payload: { query: string; componentPath: string; }; } export interface IReplaceStaticQueryAction { type: `REPLACE_STATIC_QUERY`; plugin: IGatsbyPlugin | null | undefined; payload: { name: string; componentPath: string; id: string; query: string; hash: string; }; } export interface IQueryClearDirtyQueriesListToEmitViaWebsocket { type: `QUERY_CLEAR_DIRTY_QUERIES_LIST_TO_EMIT_VIA_WEBSOCKET`; } export interface IQueryExtractedAction { type: `QUERY_EXTRACTED`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { componentPath: string; query: string; }; } export interface IQueryExtractionGraphQLErrorAction { type: `QUERY_EXTRACTION_GRAPHQL_ERROR`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { componentPath: string; error: string; }; } export interface IQueryExtractedBabelSuccessAction { type: `QUERY_EXTRACTION_BABEL_SUCCESS`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { componentPath: string; }; } export interface IQueryExtractionBabelErrorAction { type: `QUERY_EXTRACTION_BABEL_ERROR`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { componentPath: string; error: Error; }; } export interface ISetProgramStatusAction { type: `SET_PROGRAM_STATUS`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: ProgramStatus; } export interface IPageQueryRunAction { type: `PAGE_QUERY_RUN`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { path: string; componentPath: string; queryType: "page" | "static" | "slice"; resultHash: string; queryHash: string; }; } export interface IQueryStartAction { type: `QUERY_START`; plugin: IGatsbyPlugin; traceId: string | undefined; payload: { path: string; componentPath: string; isPage: boolean; }; } export interface IRemoveStaleJobAction { type: `REMOVE_STALE_JOB_V2`; plugin: IGatsbyPlugin | undefined; traceId?: string; payload: { contentDigest: string; }; } export interface IAddThirdPartySchema { type: `ADD_THIRD_PARTY_SCHEMA`; plugin: IGatsbyPlugin; traceId?: string; payload: GraphQLSchema; } export interface ICreateTypes { type: `CREATE_TYPES`; plugin: IGatsbyPlugin; traceId?: string; payload: DocumentNode | Array<DocumentNode>; } export interface ICreateFieldExtension { type: `CREATE_FIELD_EXTENSION`; plugin: IGatsbyPlugin; traceId?: string; payload: { name: string; extension: GraphQLFieldExtensionDefinition; }; } export interface IPrintTypeDefinitions { type: `PRINT_SCHEMA_REQUESTED`; plugin: IGatsbyPlugin; traceId?: string; payload: { path?: string; include?: { types?: Array<string>; plugins?: Array<string>; }; exclude?: { types?: Array<string>; plugins?: Array<string>; }; withFieldTypes?: boolean; }; } export interface ICreateResolverContext { type: `CREATE_RESOLVER_CONTEXT`; plugin: IGatsbyPlugin; traceId?: string; payload: IGatsbyPluginContext | { [camelCasedPluginNameWithoutPrefix: string]: IGatsbyPluginContext; }; } interface IClearSchemaCustomizationAction { type: `CLEAR_SCHEMA_CUSTOMIZATION`; } interface ISetSchemaComposerAction { type: `SET_SCHEMA_COMPOSER`; payload: SchemaComposer<any>; } export interface IDeleteCacheAction { type: `DELETE_CACHE`; cacheIsCorrupt?: boolean; } export interface IUpdatePluginsHashAction { type: `UPDATE_PLUGINS_HASH`; payload: Identifier; } export interface ISetPluginStatusAction { type: `SET_PLUGIN_STATUS`; plugin: IGatsbyPlugin; payload: { [key: string]: any; }; } export interface ISetSchemaAction { type: `SET_SCHEMA`; payload: IGatsbyState["schema"]; } export interface ISetGraphQLDefinitionsAction { type: `SET_GRAPHQL_DEFINITIONS`; payload: IGatsbyState["definitions"]; } export interface ISetSiteConfig { type: `SET_SITE_CONFIG`; payload: IGatsbyState["config"]; } export interface ICreateNodeAction { type: `CREATE_NODE`; payload: IGatsbyNode; oldNode?: IGatsbyNode; traceId: string; parentSpan: Span; followsSpan: Span; plugin: IGatsbyPlugin; } export interface IAddFieldToNodeAction { type: `ADD_FIELD_TO_NODE`; payload: IGatsbyNode; addedField: string; } export interface IAddChildNodeToParentNodeAction { type: `ADD_CHILD_NODE_TO_PARENT_NODE`; payload: IGatsbyNode; } export interface IDeleteNodeAction { type: `DELETE_NODE`; payload: IGatsbyNode | void; plugin: IGatsbyPlugin; isRecursiveChildrenDelete?: boolean; } export interface ISetSiteFlattenedPluginsAction { type: `SET_SITE_FLATTENED_PLUGINS`; payload: IGatsbyState["flattenedPlugins"]; } export interface ISetResolvedNodesAction { type: `SET_RESOLVED_NODES`; payload: { key: string; nodes: IGatsbyState["resolvedNodesCache"]; }; } export interface ITouchNodeAction { type: `TOUCH_NODE`; payload: Identifier; typeName: IGatsbyNode["internal"]["type"]; plugin: IGatsbyPlugin; } interface IStartIncrementalInferenceAction { type: `START_INCREMENTAL_INFERENCE`; } interface IBuildTypeMetadataAction { type: `BUILD_TYPE_METADATA`; payload: { nodes: Array<IGatsbyNode>; clearExistingMetadata: boolean; typeName: string; }; } interface IDisableTypeInferenceAction { type: `DISABLE_TYPE_INFERENCE`; payload: Array<string>; } interface ISetProgramAction { type: `SET_PROGRAM`; payload: IStateProgram; } interface ISetProgramExtensions { type: `SET_PROGRAM_EXTENSIONS`; payload: Array<string>; } export interface ISetDomainRequestHeaders { type: `SET_REQUEST_HEADERS`; payload: { domain: string; headers: { [header: string]: string; }; }; } export interface IEnableStatefulSourcePluginAction { type: `ENABLE_STATEFUL_SOURCE_PLUGIN`; plugin: IGatsbyPlugin; } export interface IProcessGatsbyImageSourceUrlAction { type: `PROCESS_GATSBY_IMAGE_SOURCE_URL`; payload: { sourceUrl: string; }; } export interface IClearGatsbyImageSourceUrlAction { type: `CLEAR_GATSBY_IMAGE_SOURCE_URL`; } export interface ITelemetry { gatsbyImageSourceUrls: Set<string>; } export interface ISetJobV2Context { type: `SET_JOB_V2_CONTEXT`; payload: { job: IGatsbyIncompleteJobV2["job"]; requestId: string; }; } export interface IClearJobV2Context { type: `CLEAR_JOB_V2_CONTEXT`; payload: { requestId: string; }; } export {}; //# sourceMappingURL=types.d.ts.map