goatly 0.1.0 → 0.1.2
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/README.md +874 -1
- package/bin/goatly.js +99 -0
- package/dist/cli/index.js +234 -0
- package/dist/compat/gatsby-node-entry.js +16 -0
- package/dist/compat/gatsby-package.json +6 -0
- package/dist/compat/md5-file.js +47 -0
- package/dist/compat-apis.json +72 -0
- package/dist/compat-apis.json.js +62 -0
- package/dist/graphql.js +3 -0
- package/dist/node/actions/index.js +619 -0
- package/dist/node/actions/job-store.js +180 -0
- package/dist/node/actions/jobs.js +174 -0
- package/dist/node/api-runner.js +258 -0
- package/dist/node/bootstrap.js +569 -0
- package/dist/node/build/assets.js +110 -0
- package/dist/node/build/incremental.js +208 -0
- package/dist/node/build/index.js +763 -0
- package/dist/node/build/memory-governor.js +450 -0
- package/dist/node/build/output-dirs.js +70 -0
- package/dist/node/build/page-data.js +40 -0
- package/dist/node/build/page-files.js +186 -0
- package/dist/node/build/partitioned-state.js +258 -0
- package/dist/node/build/query-worker.js +626 -0
- package/dist/node/build/query-workers.js +863 -0
- package/dist/node/build/render-thread.js +103 -0
- package/dist/node/build/render-worker.js +162 -0
- package/dist/node/build/state.js +24 -0
- package/dist/node/build/timing-breakdown.js +216 -0
- package/dist/node/build/work-clock.js +75 -0
- package/dist/node/build/worker-pool.js +242 -0
- package/dist/node/cache-layout.js +99 -0
- package/dist/node/cache.js +1430 -0
- package/dist/node/compat/chokidar-shim.js +148 -0
- package/dist/node/compat/core-utils-lmdb.js +145 -0
- package/dist/node/compat/create-node-id-shim.js +1 -0
- package/dist/node/compat/module-hooks.js +245 -0
- package/dist/node/compat/redux-shim.js +1 -0
- package/dist/node/config/index.js +162 -0
- package/dist/node/config/not-found-pages.js +95 -0
- package/dist/node/datastore/codec.js +144 -0
- package/dist/node/datastore/index.js +127 -0
- package/dist/node/datastore/logfile/cache.js +89 -0
- package/dist/node/datastore/logfile/index.js +1329 -0
- package/dist/node/datastore/logfile/record.js +71 -0
- package/dist/node/datastore/types.js +1 -0
- package/dist/node/develop/express-compat.js +207 -0
- package/dist/node/develop/graphiql.js +22 -0
- package/dist/node/develop/hydration-report.js +41 -0
- package/dist/node/develop/index.js +618 -0
- package/dist/node/develop/local-url.js +10 -0
- package/dist/node/develop/ssr-runner.js +66 -0
- package/dist/node/gql.js +5 -0
- package/dist/node/index.js +15 -0
- package/dist/node/info.js +270 -0
- package/dist/node/internal-plugins/data-bridge.js +196 -0
- package/dist/node/internal-plugins/page-creator.js +318 -0
- package/dist/node/loader/import-module.js +160 -0
- package/dist/node/node-helpers.js +66 -0
- package/dist/node/not-found-pages.js +220 -0
- package/dist/node/plugins/api-list.js +12 -0
- package/dist/node/plugins/load-plugins.js +427 -0
- package/dist/node/plugins/resolve-plugin.js +79 -0
- package/dist/node/plugins/static-exports.js +64 -0
- package/dist/node/query/compile.js +326 -0
- package/dist/node/query/dependencies.js +45 -0
- package/dist/node/query/execute.js +417 -0
- package/dist/node/query/extract.js +372 -0
- package/dist/node/query/gql-tada-introspection.js +124 -0
- package/dist/node/query/graphql-env.js +231 -0
- package/dist/node/query/graphql-runner.js +79 -0
- package/dist/node/redux/actions.js +1 -0
- package/dist/node/redux/index.js +133 -0
- package/dist/node/redux/node-changes.js +128 -0
- package/dist/node/redux/reducers.js +193 -0
- package/dist/node/redux/state.js +71 -0
- package/dist/node/renderer.js +124 -0
- package/dist/node/reporter-transports.js +259 -0
- package/dist/node/reporter.js +497 -0
- package/dist/node/schema/date.js +539 -0
- package/dist/node/schema/extensions.js +315 -0
- package/dist/node/schema/index.js +542 -0
- package/dist/node/schema/infer.js +388 -0
- package/dist/node/schema/inline-objects.js +128 -0
- package/dist/node/schema/naming.js +20 -0
- package/dist/node/schema/node-model.js +207 -0
- package/dist/node/schema/query-engine.js +1808 -0
- package/dist/node/schema/resolver-kinds.js +7 -0
- package/dist/node/schema/resolvers.js +273 -0
- package/dist/node/schema/type-builders.js +45 -0
- package/dist/node/schema/types.js +241 -0
- package/dist/node/serve.js +90 -0
- package/dist/node/site-page-nodes.js +277 -0
- package/dist/node/types.js +1 -0
- package/dist/node/utils/content-digest.js +107 -0
- package/dist/node/utils/cpus.js +104 -0
- package/dist/node/utils/create-node-id.js +51 -0
- package/dist/node/utils/env.js +25 -0
- package/dist/node/utils/fs-retry.js +74 -0
- package/dist/node/utils/memory-signals.js +441 -0
- package/dist/node/utils/memory.js +657 -0
- package/dist/node/utils/murmurhash.js +32 -0
- package/dist/node/utils/parser.js +33 -0
- package/dist/node/utils/partition-hash.js +19 -0
- package/dist/node/utils/paths.js +122 -0
- package/dist/node/utils/resolver.js +48 -0
- package/dist/node/utils/runtime.js +5 -0
- package/dist/node/utils/serializable.js +41 -0
- package/dist/node/utils/strings.js +41 -0
- package/dist/node/vite/config.js +289 -0
- package/dist/node/vite/paths.js +12 -0
- package/dist/node/vite/plugin-deps.js +232 -0
- package/dist/node/vite/plugin.js +283 -0
- package/dist/node/vite/react-compiler.js +362 -0
- package/dist/node/vite/source-files.js +83 -0
- package/dist/node/vite/static-image.js +136 -0
- package/dist/node/vite/styled-components.js +73 -0
- package/dist/node/vite/transforms.js +330 -0
- package/dist/node/wasm-data/host.js +406 -0
- package/dist/node/wasm-data/lower.js +406 -0
- package/dist/node/wasm-data/runner.js +79 -0
- package/dist/node/wasm-data/worker.js +95 -0
- package/dist/reporter.js +5 -0
- package/dist/runtime/api-runner.js +81 -0
- package/dist/runtime/app.js +256 -0
- package/dist/runtime/client-entry.js +4 -0
- package/dist/runtime/client.js +383 -0
- package/dist/runtime/default-html.js +31 -0
- package/dist/runtime/head-markup.js +100 -0
- package/dist/runtime/head-sync.js +101 -0
- package/dist/runtime/head-tags.js +45 -0
- package/dist/runtime/hydration-report.js +111 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/link.js +293 -0
- package/dist/runtime/loader.js +449 -0
- package/dist/runtime/not-found.js +61 -0
- package/dist/runtime/page-renderer.js +35 -0
- package/dist/runtime/preamble.js +47 -0
- package/dist/runtime/react-compat.js +14 -0
- package/dist/runtime/renderer-shared.js +10 -0
- package/dist/runtime/renderers/react-client.js +14 -0
- package/dist/runtime/renderers/react-server.js +99 -0
- package/dist/runtime/renderers/react.js +17 -0
- package/dist/runtime/renderers/types.js +1 -0
- package/dist/runtime/root-error-handlers.js +29 -0
- package/dist/runtime/router/history.js +132 -0
- package/dist/runtime/router/index.js +240 -0
- package/dist/runtime/router/utils.js +118 -0
- package/dist/runtime/script.js +110 -0
- package/dist/runtime/scroll.js +40 -0
- package/dist/runtime/slice.js +11 -0
- package/dist/runtime/ssr.js +240 -0
- package/dist/runtime/static-query.js +47 -0
- package/dist/utils.js +4 -0
- package/package.json +105 -3
- package/types/graphql-tada.d.ts +223 -0
- package/types/graphql.d.ts +2 -0
- package/types/index.d.ts +2287 -0
- package/types/node.d.ts +389 -0
- package/types/reporter.d.ts +187 -0
- package/types/router.d.ts +102 -0
- package/types/vendor/gql-tada.d.ts +2529 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,2287 @@
|
|
|
1
|
+
// Type definitions for goatly – API compatible with Gatsby 5.
|
|
2
|
+
// Based on Gatsby's index.d.ts (MIT License, Copyright (c) 2015 gatsbyjs).
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { EventEmitter } from "events"
|
|
5
|
+
import type { WindowLocation, NavigateOptions } from "./router.js"
|
|
6
|
+
import type {
|
|
7
|
+
EnumTypeComposerAsObjectDefinition as ComposeEnumTypeConfig,
|
|
8
|
+
InputTypeComposerAsObjectDefinition as ComposeInputObjectTypeConfig,
|
|
9
|
+
InterfaceTypeComposerAsObjectDefinition as ComposeInterfaceTypeConfig,
|
|
10
|
+
ObjectTypeComposerAsObjectDefinition as ComposeObjectTypeConfig,
|
|
11
|
+
ScalarTypeComposerAsObjectDefinition as ComposeScalarTypeConfig,
|
|
12
|
+
UnionTypeComposerAsObjectDefinition as ComposeUnionTypeConfig,
|
|
13
|
+
} from "graphql-compose"
|
|
14
|
+
import type { GraphQLOutputType } from "graphql"
|
|
15
|
+
import type { Root as JoiRoot, ObjectSchema } from "joi"
|
|
16
|
+
import type { IncomingMessage, ServerResponse } from "http"
|
|
17
|
+
import type { Reporter } from "./reporter.js"
|
|
18
|
+
import type {
|
|
19
|
+
DataOfQuery,
|
|
20
|
+
FragmentName,
|
|
21
|
+
FragmentOf,
|
|
22
|
+
FragmentResult,
|
|
23
|
+
GraphQLDocument,
|
|
24
|
+
GraphQLDocumentCheck,
|
|
25
|
+
GraphQLDocumentOf,
|
|
26
|
+
HasGraphQLTypes,
|
|
27
|
+
NodeQueryData,
|
|
28
|
+
QueryName,
|
|
29
|
+
QueryResult,
|
|
30
|
+
QueryVariables,
|
|
31
|
+
ResultOf,
|
|
32
|
+
VariablesOf,
|
|
33
|
+
} from "./graphql-tada.js"
|
|
34
|
+
export type { Reporter }
|
|
35
|
+
/** The result type of a `graphql()` document: `PageProps<ResultOf<typeof query>>` */
|
|
36
|
+
export type { ResultOf }
|
|
37
|
+
/** The variables type of a `graphql()` document: `VariablesOf<typeof query>` */
|
|
38
|
+
export type { VariablesOf }
|
|
39
|
+
/** The result type of a `graphql()` fragment document (fragments are not masked) */
|
|
40
|
+
export type { FragmentOf }
|
|
41
|
+
export type { GraphQLDocument }
|
|
42
|
+
/** The data of the site's query named `Name` (tag or `graphql()` call): `QueryResult<"Name">` */
|
|
43
|
+
export type { QueryResult, QueryVariables, FragmentResult, QueryName, FragmentName }
|
|
44
|
+
|
|
45
|
+
/** Minimal OpenTracing span (tracing is a no-op in goatly) */
|
|
46
|
+
export interface Span {
|
|
47
|
+
setTag(key: string, value: unknown): Span
|
|
48
|
+
finish(): void
|
|
49
|
+
[key: string]: unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type PluginOptionsSchemaJoi = JoiRoot & {
|
|
53
|
+
subPlugins(options?: { entry?: string }): any
|
|
54
|
+
}
|
|
55
|
+
export type { ObjectSchema }
|
|
56
|
+
|
|
57
|
+
// Adapters are accepted for config compatibility (goatly only builds static sites)
|
|
58
|
+
export type IAdapter = { name: string; [key: string]: unknown }
|
|
59
|
+
export type AdapterInit<T = Record<string, unknown>> = (options?: T) => IAdapter
|
|
60
|
+
export type IStaticRoute = Record<string, unknown>
|
|
61
|
+
export type IFunctionRoute = Record<string, unknown>
|
|
62
|
+
export type IRedirectRoute = Record<string, unknown>
|
|
63
|
+
export type IFunctionDefinition = Record<string, unknown>
|
|
64
|
+
export type RoutesManifest = Array<Record<string, unknown>>
|
|
65
|
+
export type HeaderRoutes = Array<Record<string, unknown>>
|
|
66
|
+
export type FunctionsManifest = Array<Record<string, unknown>>
|
|
67
|
+
export type IAdapterConfig = Record<string, unknown>
|
|
68
|
+
export type ImageCdnUrlGeneratorFn = (...args: any[]) => string
|
|
69
|
+
export type ImageCdnSourceImage = Record<string, unknown>
|
|
70
|
+
export type ImageCdnTransformArgs = Record<string, unknown>
|
|
71
|
+
export type FileCdnUrlGeneratorFn = (...args: any[]) => string
|
|
72
|
+
export type FileCdnSourceImage = Record<string, unknown>
|
|
73
|
+
export type RemoteFileAllowedUrls = Array<{ urlPattern: string; url?: string }>
|
|
74
|
+
|
|
75
|
+
export type AvailableFeatures =
|
|
76
|
+
| "image-cdn"
|
|
77
|
+
| "graphql-typegen"
|
|
78
|
+
| "content-file-path"
|
|
79
|
+
| "stateful-source-nodes"
|
|
80
|
+
| "adapters"
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* goatly: when a link prefetches its page:
|
|
84
|
+
* - `"viewport"` / `true` (default, like Gatsby): once the link is visible, and on intent (hover,
|
|
85
|
+
* focus, touch)
|
|
86
|
+
* - `"intent"`: only on intent
|
|
87
|
+
* - `false`: never
|
|
88
|
+
*/
|
|
89
|
+
export type LinkPrefetch = boolean | "viewport" | "intent"
|
|
90
|
+
|
|
91
|
+
export interface GatsbyLinkProps<TState = any> extends Omit<
|
|
92
|
+
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
93
|
+
"href" | "ref"
|
|
94
|
+
> {
|
|
95
|
+
/** A class to apply when this Link is active */
|
|
96
|
+
activeClassName?: string
|
|
97
|
+
/** Inline styles for when this Link is active */
|
|
98
|
+
activeStyle?: object
|
|
99
|
+
innerRef?: React.Ref<HTMLAnchorElement>
|
|
100
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void
|
|
101
|
+
/** Class the link as highlighted if there is a partial match via a the `to` being prefixed to the current url */
|
|
102
|
+
partiallyActive?: boolean
|
|
103
|
+
/** Used to declare that this link replaces the current URL in history with the target */
|
|
104
|
+
replace?: boolean
|
|
105
|
+
/** Used to pass state data to the linked page. */
|
|
106
|
+
state?: TState
|
|
107
|
+
/** The URL you want to link to */
|
|
108
|
+
to: string
|
|
109
|
+
/** goatly: when the linked page is prefetched (default: the `LinkProvider`'s or gatsby-config's `prefetch`) */
|
|
110
|
+
prefetch?: LinkPrefetch
|
|
111
|
+
getProps?: (props: {
|
|
112
|
+
isCurrent: boolean
|
|
113
|
+
isPartiallyCurrent: boolean
|
|
114
|
+
href: string
|
|
115
|
+
location: WindowLocation
|
|
116
|
+
}) => object | undefined | null
|
|
117
|
+
children?: React.ReactNode
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Props of `<Link as={Component}>`: the Link's props plus those of `Component` */
|
|
121
|
+
export type LinkProps<
|
|
122
|
+
TState = any,
|
|
123
|
+
TAs extends React.ElementType = "a",
|
|
124
|
+
> = GatsbyLinkProps<TState> & {
|
|
125
|
+
/**
|
|
126
|
+
* goatly: the element or component to render instead of `<a>`. It gets `href`, `onClick`,
|
|
127
|
+
* `onMouseEnter`, `onMouseLeave`, `onFocus`, `onPointerDown`, `aria-current`, `className`/`style` (with the active ones) and the
|
|
128
|
+
* other props, and should forward its `ref` to the DOM element for `"viewport"` prefetching.
|
|
129
|
+
*/
|
|
130
|
+
as?: TAs
|
|
131
|
+
ref?: React.Ref<React.ComponentRef<TAs>>
|
|
132
|
+
} & Omit<React.ComponentPropsWithoutRef<TAs>, keyof GatsbyLinkProps<TState> | "as" | "href">
|
|
133
|
+
|
|
134
|
+
/** Gatsby's `<Link>`: client-side navigation with prefetching */
|
|
135
|
+
export const Link: <TState = any, TAs extends React.ElementType = "a">(
|
|
136
|
+
props: LinkProps<TState, TAs>,
|
|
137
|
+
) => React.ReactElement | null
|
|
138
|
+
|
|
139
|
+
/** goatly: what a link knows about its target and the current location */
|
|
140
|
+
export interface LinkState {
|
|
141
|
+
/** The final `href` (path prefix and `trailingSlash` applied, relative paths resolved) */
|
|
142
|
+
href: string
|
|
143
|
+
/** The link points to the current page */
|
|
144
|
+
isCurrent: boolean
|
|
145
|
+
/** The current page's path starts with the link's path */
|
|
146
|
+
isPartiallyCurrent: boolean
|
|
147
|
+
/** `isCurrent`, or `isPartiallyCurrent` with `partiallyActive` */
|
|
148
|
+
isActive: boolean
|
|
149
|
+
/** `to` has a scheme (`https:`, `mailto:`, …): a plain link, no client-side navigation */
|
|
150
|
+
isExternal: boolean
|
|
151
|
+
location: WindowLocation
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface UseLinkOptions<TState = any> {
|
|
155
|
+
to: string
|
|
156
|
+
state?: TState
|
|
157
|
+
replace?: boolean
|
|
158
|
+
partiallyActive?: boolean
|
|
159
|
+
prefetch?: LinkPrefetch
|
|
160
|
+
/** Links with a `target` are left to the browser */
|
|
161
|
+
target?: string
|
|
162
|
+
onClick?: (event: React.MouseEvent<any>) => void
|
|
163
|
+
onMouseEnter?: (event: React.MouseEvent<any>) => void
|
|
164
|
+
onMouseLeave?: (event: React.MouseEvent<any>) => void
|
|
165
|
+
onFocus?: (event: React.FocusEvent<any>) => void
|
|
166
|
+
onPointerDown?: (event: React.PointerEvent<any>) => void
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Props to spread on the element that renders the link (an `<a>` or a component that renders one) */
|
|
170
|
+
export interface LinkElementProps {
|
|
171
|
+
href: string
|
|
172
|
+
ref: (element: HTMLElement | null) => void
|
|
173
|
+
onClick: (event: React.MouseEvent<any>) => void
|
|
174
|
+
onMouseEnter: (event: React.MouseEvent<any>) => void
|
|
175
|
+
onMouseLeave: (event: React.MouseEvent<any>) => void
|
|
176
|
+
onFocus: (event: React.FocusEvent<any>) => void
|
|
177
|
+
onPointerDown: (event: React.PointerEvent<any>) => void
|
|
178
|
+
"aria-current"?: "page"
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface UseLinkResult extends LinkState {
|
|
182
|
+
linkProps: LinkElementProps
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* goatly: the behavior of `<Link>` without its markup (path prefix, `trailingSlash`,
|
|
187
|
+
* relative paths, active state, prefetching, client-side navigation). Spread `linkProps` on any
|
|
188
|
+
* element or component that renders an `<a>`; `ref` (merged into `linkProps.ref`) is optional.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* function NavButton({ to, children }) {
|
|
192
|
+
* const { linkProps, isActive } = useLink({ to })
|
|
193
|
+
* return <Button component="a" {...linkProps} variant={isActive ? "contained" : "text"}>{children}</Button>
|
|
194
|
+
* }
|
|
195
|
+
*/
|
|
196
|
+
export function useLink<TState = any>(
|
|
197
|
+
options: UseLinkOptions<TState>,
|
|
198
|
+
ref?: React.Ref<any>,
|
|
199
|
+
): UseLinkResult
|
|
200
|
+
|
|
201
|
+
export interface LinkConfig {
|
|
202
|
+
/**
|
|
203
|
+
* Renders every `<Link>` below the provider instead of the built-in one, also those of plugins
|
|
204
|
+
* and themes. It gets the `<Link>`'s props and its `ref`. A `<Link>` it renders itself is the
|
|
205
|
+
* built-in one, so it can wrap it: `forwardRef((props, ref) => <Link {...props} ref={ref} />)`.
|
|
206
|
+
*/
|
|
207
|
+
component?: React.ComponentType<any>
|
|
208
|
+
/** Default `prefetch` of the links (instead of gatsby-config's `prefetch`) */
|
|
209
|
+
prefetch?: LinkPrefetch
|
|
210
|
+
/** Default `activeClassName` of the links */
|
|
211
|
+
activeClassName?: string
|
|
212
|
+
/** Default `activeStyle` of the links */
|
|
213
|
+
activeStyle?: object
|
|
214
|
+
/** Default `partiallyActive` of the links */
|
|
215
|
+
partiallyActive?: boolean
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* goatly: configures the `<Link>`s and `useLink`s below it, with defaults for their props or
|
|
220
|
+
* a `component` that replaces them. Nested providers override the values they set. Return it from
|
|
221
|
+
* `wrapRootElement` to configure every link of the site.
|
|
222
|
+
*/
|
|
223
|
+
export function LinkProvider(props: LinkConfig & { children?: React.ReactNode }): React.ReactElement
|
|
224
|
+
/** goatly: the merged configuration of the closest `LinkProvider`s (`{}` without one) */
|
|
225
|
+
export function useLinkConfig(): LinkConfig
|
|
226
|
+
|
|
227
|
+
/** Programmatic navigation (Gatsby `navigate`) */
|
|
228
|
+
export function navigate(to: string, options?: NavigateOptions<{}>): void
|
|
229
|
+
export function navigate(to: number): void
|
|
230
|
+
/** Prefix a path with the site's pathPrefix (when building with --prefix-paths) */
|
|
231
|
+
export function withPrefix(path: string, prefix?: string): string
|
|
232
|
+
export function withAssetPrefix(path: string): string
|
|
233
|
+
|
|
234
|
+
export enum ScriptStrategy {
|
|
235
|
+
postHydrate = "post-hydrate",
|
|
236
|
+
idle = "idle",
|
|
237
|
+
/** Partytown in Gatsby – goatly runs these scripts on the main thread, like `idle` */
|
|
238
|
+
offMainThread = "off-main-thread",
|
|
239
|
+
}
|
|
240
|
+
export interface ScriptProps extends Omit<
|
|
241
|
+
React.ScriptHTMLAttributes<HTMLScriptElement>,
|
|
242
|
+
"onLoad" | "onError"
|
|
243
|
+
> {
|
|
244
|
+
id?: string
|
|
245
|
+
strategy?: ScriptStrategy | `post-hydrate` | `idle` | `off-main-thread`
|
|
246
|
+
children?: string
|
|
247
|
+
onLoad?: (event: Event) => void
|
|
248
|
+
onError?: (event: ErrorEvent) => void
|
|
249
|
+
/** Partytown `forward` entries in Gatsby (ignored by goatly) */
|
|
250
|
+
forward?: Array<string>
|
|
251
|
+
}
|
|
252
|
+
export function Script(props: ScriptProps): React.ReactElement | null
|
|
253
|
+
export const scriptCache: Set<string>
|
|
254
|
+
export const scriptCallbackCache: Map<string, unknown>
|
|
255
|
+
/** Gatsby collects off-main-thread scripts here for Partytown (always empty in goatly) */
|
|
256
|
+
export const collectedScriptsByPage: Map<string, Array<ScriptProps>>
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* goatly: `<html>` / `<body>` elements inside a `Head` export are compiled to these
|
|
260
|
+
* components (React 19 treats `<html>`/`<body>` as document singletons; React 18 cannot render them inside a Head either). They can also be used directly.
|
|
261
|
+
*/
|
|
262
|
+
export function HtmlAttributes(
|
|
263
|
+
props: React.HTMLAttributes<HTMLHtmlElement> & Record<string, unknown>,
|
|
264
|
+
): null
|
|
265
|
+
export function BodyAttributes(
|
|
266
|
+
props: React.HTMLAttributes<HTMLBodyElement> & Record<string, unknown>,
|
|
267
|
+
): null
|
|
268
|
+
|
|
269
|
+
export class StaticQueryDocument {
|
|
270
|
+
/** Prevents structural type widening. */
|
|
271
|
+
#kind: "StaticQueryDocument"
|
|
272
|
+
|
|
273
|
+
/** Allows type-safe access to the static query hash for debugging purposes. */
|
|
274
|
+
toString(): string
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* A React Hooks version of StaticQuery.
|
|
279
|
+
*
|
|
280
|
+
* StaticQuery can do most of the things that page query can, including fragments. The main differences are:
|
|
281
|
+
*
|
|
282
|
+
* - page queries can accept variables (via `pageContext`) but can only be added to _page_ components
|
|
283
|
+
* - StaticQuery does not accept variables (hence the name "static"), but can be used in _any_ component, including pages
|
|
284
|
+
*
|
|
285
|
+
* @see https://www.gatsbyjs.com/docs/how-to/querying-data/use-static-query/
|
|
286
|
+
*/
|
|
287
|
+
export const useStaticQuery: <
|
|
288
|
+
TData = never,
|
|
289
|
+
TQuery extends StaticQueryDocument = StaticQueryDocument,
|
|
290
|
+
>(
|
|
291
|
+
query: TQuery,
|
|
292
|
+
) => [TData] extends [never] ? DataOfQuery<TQuery> : NoInferData<TData>
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* `T`, not inferred from the contextual type (so that `const data: Wrong = useStaticQuery(query)`
|
|
296
|
+
* doesn't override a typed query's data). TypeScript 5.4's `NoInfer`, for older versions.
|
|
297
|
+
*/
|
|
298
|
+
type NoInferData<T> = [T][T extends any ? 0 : never]
|
|
299
|
+
|
|
300
|
+
export const parsePath: (path: string) => WindowLocation
|
|
301
|
+
|
|
302
|
+
export const prefetchPathname: (path: string) => void
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* A props object for adding type safety to your Gatsby pages, can be
|
|
306
|
+
* extended with both the query response shape, and the page context.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* // When typing a default page from the ./pages dir
|
|
310
|
+
*
|
|
311
|
+
* import {PageProps} from "gatsby"
|
|
312
|
+
* export default (props: PageProps) => {
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* // When adding types for both pageContext (represented by LocaleLookUpInfo)
|
|
316
|
+
* // and GraphQL query data (represented by IndexQueryProps)
|
|
317
|
+
*
|
|
318
|
+
* import {PageProps} from "gatsby"
|
|
319
|
+
*
|
|
320
|
+
* type IndexQueryProps = { downloadCount: number }
|
|
321
|
+
* type LocaleLookUpInfo = { translationStrings: any } & { langKey: string, slug: string }
|
|
322
|
+
* type IndexPageProps = PageProps<IndexQueryProps, LocaleLookUpInfo>
|
|
323
|
+
*
|
|
324
|
+
* export default (props: IndexPageProps) => {
|
|
325
|
+
* ..
|
|
326
|
+
*/
|
|
327
|
+
export type PageProps<
|
|
328
|
+
DataType = object,
|
|
329
|
+
PageContextType = object,
|
|
330
|
+
LocationState = WindowLocation["state"],
|
|
331
|
+
ServerDataType = object,
|
|
332
|
+
> = {
|
|
333
|
+
/** The path for this current page */
|
|
334
|
+
path: string
|
|
335
|
+
/** The URI for the current page */
|
|
336
|
+
uri: string
|
|
337
|
+
/** An extended version of window.document which comes from @react/router */
|
|
338
|
+
location: WindowLocation<LocationState>
|
|
339
|
+
/** You can't get passed children as this is the root user-land component */
|
|
340
|
+
children: undefined
|
|
341
|
+
/** The URL parameters when the page has a `matchPath` */
|
|
342
|
+
params: Record<string, string>
|
|
343
|
+
/** Holds information about the build process for this component */
|
|
344
|
+
pageResources: {
|
|
345
|
+
component: React.Component
|
|
346
|
+
json: {
|
|
347
|
+
data: DataType
|
|
348
|
+
pageContext: PageContextType
|
|
349
|
+
}
|
|
350
|
+
page: {
|
|
351
|
+
componentChunkName: string
|
|
352
|
+
path: string
|
|
353
|
+
webpackCompilationHash: string
|
|
354
|
+
matchPath?: string
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Data passed into the page via an exported GraphQL query. To set up this type
|
|
359
|
+
* you need to use [generics](https://www.typescriptlang.org/play/#example/generic-functions),
|
|
360
|
+
* see below for an example
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
*
|
|
364
|
+
* import {PageProps} from "gatsby"
|
|
365
|
+
*
|
|
366
|
+
* type IndexQueryProps = { downloadCount: number }
|
|
367
|
+
* type IndexPageProps = PageProps<IndexQueryProps>
|
|
368
|
+
*
|
|
369
|
+
* export default (props: IndexPageProps) => {
|
|
370
|
+
* ..
|
|
371
|
+
*
|
|
372
|
+
* With a `graphql()` query: `PageProps<ResultOf<typeof query>>`.
|
|
373
|
+
*/
|
|
374
|
+
data: DataType
|
|
375
|
+
/**
|
|
376
|
+
* A context object which is passed in during the creation of the page. Can be extended if you are using
|
|
377
|
+
* `createPage` yourself using generics:
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
*
|
|
381
|
+
* import {PageProps} from "gatsby"
|
|
382
|
+
*
|
|
383
|
+
* type IndexQueryProps = { downloadCount: number }
|
|
384
|
+
* type LocaleLookUpInfo = { translationStrings: any } & { langKey: string, slug: string }
|
|
385
|
+
* type IndexPageProps = PageProps<IndexQueryProps, LocaleLookUpInfo>
|
|
386
|
+
*
|
|
387
|
+
* export default (props: IndexPageProps) => {
|
|
388
|
+
* ..
|
|
389
|
+
*/
|
|
390
|
+
pageContext: PageContextType
|
|
391
|
+
/** Data passed into the page via the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) SSR function. */
|
|
392
|
+
serverData: ServerDataType
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* A props object passed into the Head function for [Gatsby Head API](https://gatsby.dev/gatsby-head).
|
|
397
|
+
*/
|
|
398
|
+
export type HeadProps<DataType = object, PageContextType = object, ServerDataType = object> = {
|
|
399
|
+
location: {
|
|
400
|
+
/**
|
|
401
|
+
* Returns the Location object's URL's path.
|
|
402
|
+
*/
|
|
403
|
+
pathname: string
|
|
404
|
+
}
|
|
405
|
+
/** The URL parameters when the page has a `matchPath` */
|
|
406
|
+
params: Record<string, string>
|
|
407
|
+
/**
|
|
408
|
+
* Data passed into the page via an exported GraphQL query (with a `graphql()` query:
|
|
409
|
+
* `HeadProps<ResultOf<typeof query>>`).
|
|
410
|
+
*/
|
|
411
|
+
data: DataType
|
|
412
|
+
/**
|
|
413
|
+
* A context object which is passed in during the creation of the page.
|
|
414
|
+
*/
|
|
415
|
+
pageContext: PageContextType
|
|
416
|
+
/**
|
|
417
|
+
* Data passed into the page via the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) SSR function.
|
|
418
|
+
*/
|
|
419
|
+
serverData: ServerDataType
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* A shorthand type for combining the props and return type for the [Gatsby Head API](https://gatsby.dev/gatsby-head).
|
|
424
|
+
*/
|
|
425
|
+
export type HeadFC<DataType = object, PageContextType = object> = (
|
|
426
|
+
props: HeadProps<DataType, PageContextType>,
|
|
427
|
+
) => React.ReactElement
|
|
428
|
+
|
|
429
|
+
type SerializableProps =
|
|
430
|
+
| ISerializableObject
|
|
431
|
+
| Array<SerializableProps>
|
|
432
|
+
| string
|
|
433
|
+
| number
|
|
434
|
+
| boolean
|
|
435
|
+
| null
|
|
436
|
+
| undefined
|
|
437
|
+
|
|
438
|
+
interface ISerializableObject {
|
|
439
|
+
[key: string]: SerializableProps
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* A props object for [slice placholder](https://gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/)
|
|
444
|
+
*/
|
|
445
|
+
export interface SlicePlaceholderProps {
|
|
446
|
+
alias: string
|
|
447
|
+
allowEmpty?: boolean
|
|
448
|
+
children?: React.ReactNode
|
|
449
|
+
[key: string]: SerializableProps | React.ReactNode
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Component used as a slice placholder, to mark a place in the page where a [slice](https://gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/) should be inserted.
|
|
454
|
+
* goatly does not support Slices: rendering a `<Slice>` fails the build (render the slice component directly); with `allowEmpty` it renders nothing.
|
|
455
|
+
*/
|
|
456
|
+
export declare function Slice(props: SlicePlaceholderProps): React.ReactElement
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* A props object for [slice component](https://gatsbyjs.com/docs/reference/built-in-components/gatsby-slice/)
|
|
460
|
+
*/
|
|
461
|
+
export type SliceComponentProps<
|
|
462
|
+
DataType = object,
|
|
463
|
+
SliceContextType = object,
|
|
464
|
+
AdditionalSerializableProps extends ISerializableObject = object,
|
|
465
|
+
> = {
|
|
466
|
+
data: DataType
|
|
467
|
+
sliceContext: SliceContextType
|
|
468
|
+
children?: React.ReactNode
|
|
469
|
+
} & AdditionalSerializableProps
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Props object passed into the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) function.
|
|
473
|
+
*/
|
|
474
|
+
export type GetServerDataProps = {
|
|
475
|
+
headers: Map<string, unknown>
|
|
476
|
+
method: string
|
|
477
|
+
url: string
|
|
478
|
+
query?: Record<string, unknown>
|
|
479
|
+
params?: Record<string, unknown>
|
|
480
|
+
pageContext: Record<string, unknown>
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* The return type (promise payload) from the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) function.
|
|
485
|
+
*/
|
|
486
|
+
export type GetServerDataReturn<ServerDataType = Record<string, unknown>> = Promise<{
|
|
487
|
+
headers?: Record<string, unknown>
|
|
488
|
+
props?: ServerDataType
|
|
489
|
+
status?: number
|
|
490
|
+
}>
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* A shorthand type for combining the props and return type for the [getServerData](https://www.gatsbyjs.com/docs/reference/rendering-options/server-side-rendering/) function.
|
|
494
|
+
*/
|
|
495
|
+
export type GetServerData<ServerDataType> = (
|
|
496
|
+
props: GetServerDataProps,
|
|
497
|
+
) => GetServerDataReturn<ServerDataType>
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Constructor arguments for the PageRenderer.
|
|
501
|
+
*/
|
|
502
|
+
export interface PageRendererProps {
|
|
503
|
+
location: WindowLocation
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* PageRenderer's constructor [loads the page resources](https://www.gatsbyjs.com/docs/production-app/#load-page-resources) for the path.
|
|
508
|
+
*
|
|
509
|
+
* On first load though, these will have already been requested from the server by `<link rel="preload" ... />` in the page's original HTML (see [Link Preloads](https://www.gatsbyjs.com/docs/how-code-splitting-works/#construct-link-and-script-tags-for-current-page) in HTML Generation Docs).
|
|
510
|
+
* The loaded page resources includes the imported component, with which we create the actual page component using [React.createElement()](https://reactjs.org/docs/react-api.html). This element is returned to our RouteHandler which hands it off to Reach Router for rendering.
|
|
511
|
+
*
|
|
512
|
+
* @see https://www.gatsbyjs.com/docs/production-app/#page-rendering
|
|
513
|
+
*/
|
|
514
|
+
export class PageRenderer extends React.Component<PageRendererProps> {}
|
|
515
|
+
|
|
516
|
+
type RenderCallback<T = any> = (data: T) => React.ReactNode
|
|
517
|
+
|
|
518
|
+
export interface StaticQueryProps<T = any> {
|
|
519
|
+
query: GraphQLDocument<T, any, any>
|
|
520
|
+
render?: RenderCallback<T>
|
|
521
|
+
children?: RenderCallback<T>
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* StaticQuery can do most of the things that page query can, including fragments. The main differences are:
|
|
526
|
+
*
|
|
527
|
+
* - page queries can accept variables (via `pageContext`) but can only be added to _page_ components
|
|
528
|
+
* - StaticQuery does not accept variables (hence the name "static"), but can be used in _any_ component, including pages
|
|
529
|
+
* - StaticQuery does not work with raw React.createElement calls; please use JSX, e.g. `<StaticQuery />`
|
|
530
|
+
*
|
|
531
|
+
* @see https://www.gatsbyjs.com/docs/static-query/
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
export class StaticQuery<T = any> extends React.Component<StaticQueryProps<T>> {}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* graphql is a tag function. Behind the scenes Gatsby handles these tags in a particular way
|
|
538
|
+
*
|
|
539
|
+
* During the Gatsby build process, GraphQL queries are pulled out of the original source for parsing.
|
|
540
|
+
*
|
|
541
|
+
* @see https://www.gatsbyjs.com/docs/page-query#how-does-the-graphql-tag-work
|
|
542
|
+
*/
|
|
543
|
+
export interface GraphQLFunction {
|
|
544
|
+
/**
|
|
545
|
+
* gql.tada's form: `graphql(\`query { ... }\`)`, typed with the site's schema and fragments (from
|
|
546
|
+
* the declaration file goatly generates, `src/gatsby-graphql-env.d.ts` in TypeScript
|
|
547
|
+
* sites). All fragments of the site can be spread by name, like with tags; fragment documents can
|
|
548
|
+
* also be passed as the second argument. Compiled away like the tags.
|
|
549
|
+
*/
|
|
550
|
+
<Source extends string, Fragments extends readonly GraphQLDocument<any, any, any>[] = []>(
|
|
551
|
+
source: Source & GraphQLDocumentCheck<Source, Fragments>,
|
|
552
|
+
fragments?: Fragments,
|
|
553
|
+
): GraphQLDocumentOf<Source, Fragments>
|
|
554
|
+
/** Gatsby's tagged template: `graphql\`query { ... }\`` (its result type is not known; the last
|
|
555
|
+
* signature, so that `ReturnType<typeof graphql>` is `StaticQueryDocument` as in Gatsby). */
|
|
556
|
+
(query: TemplateStringsArray): StaticQueryDocument
|
|
557
|
+
}
|
|
558
|
+
export const graphql: GraphQLFunction
|
|
559
|
+
|
|
560
|
+
export interface GraphQLTypegenOptions {
|
|
561
|
+
typesOutputPath?: string
|
|
562
|
+
documentSearchPaths?: string[]
|
|
563
|
+
generateOnBuild?: boolean
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
type Proxy = {
|
|
567
|
+
prefix: string
|
|
568
|
+
url: string
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
type Header = {
|
|
572
|
+
/**
|
|
573
|
+
* The path to match requests against.
|
|
574
|
+
*/
|
|
575
|
+
source: string
|
|
576
|
+
/**
|
|
577
|
+
* Your custom response headers.
|
|
578
|
+
*/
|
|
579
|
+
headers: Array<{
|
|
580
|
+
key: string
|
|
581
|
+
value: string
|
|
582
|
+
}>
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Gatsby configuration API.
|
|
587
|
+
*
|
|
588
|
+
* @see https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/
|
|
589
|
+
*/
|
|
590
|
+
export interface GatsbyConfig {
|
|
591
|
+
/** When you want to reuse common pieces of data across the site (for example, your site title), you can store that here. */
|
|
592
|
+
siteMetadata?: Record<string, unknown>
|
|
593
|
+
/** Plugins are Node.js packages that implement Gatsby APIs. The config file accepts an array of plugins. Some plugins may need only to be listed by name, while others may take options. */
|
|
594
|
+
plugins?: Array<PluginRef>
|
|
595
|
+
/** You can activate and deactivate current experiments here. These are experimental features that are currently under development and need testing. When opting in to an experiment you'll receive a console message with more information of what it does and a link to an umbrella discussion. */
|
|
596
|
+
flags?: Record<string, boolean>
|
|
597
|
+
/** It’s common for sites to be hosted somewhere other than the root of their domain. Say we have a Gatsby site at `example.com/blog/`. In this case, we would need a prefix (`/blog`) added to all paths on the site. */
|
|
598
|
+
pathPrefix?: string
|
|
599
|
+
/** `never` removes all trailing slashes, `always` adds it, and `ignore` doesn't automatically change anything and it's in user hands to keep things consistent. By default `always` is used. */
|
|
600
|
+
trailingSlash?: "always" | "never" | "ignore"
|
|
601
|
+
/** In some circumstances you may want to deploy assets (non-HTML resources such as JavaScript, CSS, etc.) to a separate domain. `assetPrefix` allows you to use Gatsby with assets hosted from a separate domain */
|
|
602
|
+
assetPrefix?: string
|
|
603
|
+
/** More easily incorporate content into your pages through automatic TypeScript type generation and better GraphQL IntelliSense. If set to true, the default GraphQLTypegenOptions are used. See https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/ for all options. */
|
|
604
|
+
graphqlTypegen?: boolean | GraphQLTypegenOptions
|
|
605
|
+
/** Gatsby uses the ES6 Promise API. Because some browsers don't support this, Gatsby includes a Promise polyfill by default. If you'd like to provide your own Promise polyfill, you can set `polyfill` to false.*/
|
|
606
|
+
polyfill?: boolean
|
|
607
|
+
mapping?: Record<string, string>
|
|
608
|
+
jsxRuntime?: "automatic" | "classic"
|
|
609
|
+
jsxImportSource?: string
|
|
610
|
+
/**
|
|
611
|
+
* Setting the proxy config option will tell the develop server to proxy any unknown requests to your specified server.
|
|
612
|
+
* @see https://www.gatsbyjs.com/docs/api-proxy/
|
|
613
|
+
* */
|
|
614
|
+
proxy?: Proxy | Proxy[]
|
|
615
|
+
/**
|
|
616
|
+
* A list of trusted URLs that will be proxied for use with the gatsby-script off-main-thread strategy.
|
|
617
|
+
* (accepted for compatibility, not used: goatly has no Partytown)
|
|
618
|
+
* @see https://gatsby.dev/gatsby-script
|
|
619
|
+
*/
|
|
620
|
+
partytownProxiedURLs?: Array<string>
|
|
621
|
+
/** Sometimes you need more granular/flexible access to the development server. Gatsby exposes the Express.js development server to your site’s gatsby-config.js where you can add Express middleware as needed. */
|
|
622
|
+
developMiddleware?(app: any): void
|
|
623
|
+
/**
|
|
624
|
+
* You can set custom HTTP headers on the response of a given path. This allows you to, e.g. modify the caching behavior or configure access control. You can apply HTTP headers to static routes and redirects.
|
|
625
|
+
* @see http://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/headers/
|
|
626
|
+
*/
|
|
627
|
+
headers?: Array<Header>
|
|
628
|
+
/**
|
|
629
|
+
* Adapters are responsible for taking the production output from Gatsby and turning it into something your deployment platform understands. They make it easier to build and deploy Gatsby on any deployment platform.
|
|
630
|
+
* @see http://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/adapters/
|
|
631
|
+
*/
|
|
632
|
+
adapter?: IAdapter
|
|
633
|
+
|
|
634
|
+
// ---- goatly extensions -------------------------------------------------------------
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Pluggable node storage. Default: the logfile store (nodes in append-only segment files in
|
|
638
|
+
* `.cache`, read through the OS page cache); see also the SQLite datastore package.
|
|
639
|
+
*/
|
|
640
|
+
datastore?: DataStore | ((ctx: { cacheDir: string }) => DataStore | Promise<DataStore>)
|
|
641
|
+
/**
|
|
642
|
+
* goatly: where reporter output goes (default: the console), e.g.
|
|
643
|
+
* `reporter: loggerTransport(winstonLogger)` – see `gatsby/reporter`
|
|
644
|
+
*/
|
|
645
|
+
reporter?:
|
|
646
|
+
| import("./reporter.js").ReporterTransport
|
|
647
|
+
| Array<import("./reporter.js").ReporterTransport>
|
|
648
|
+
/** Additional Vite configuration, merged into the generated config (for all stages). */
|
|
649
|
+
vite?:
|
|
650
|
+
| Record<string, any>
|
|
651
|
+
| ((env: {
|
|
652
|
+
command: "build" | "serve"
|
|
653
|
+
stage: GatsbyStages
|
|
654
|
+
}) => Record<string, any> | Promise<Record<string, any>>)
|
|
655
|
+
/** Worker threads used for parallel query running and HTML rendering (default: CPU cores - 1). */
|
|
656
|
+
renderWorkers?: number
|
|
657
|
+
/** Run page queries in worker threads (default: true for sites with 500+ pages). */
|
|
658
|
+
parallelQueryRunning?: boolean
|
|
659
|
+
/** Inline page-data into the HTML instead of fetching page-data.json on first load. */
|
|
660
|
+
inlinePageData?: boolean
|
|
661
|
+
/** Inline CSS into `<style>` tags (Gatsby's default) instead of `<link rel="stylesheet">`. */
|
|
662
|
+
inlineCss?: boolean
|
|
663
|
+
/** Server-render pages in `develop` (default: true). */
|
|
664
|
+
devSSR?: boolean
|
|
665
|
+
/**
|
|
666
|
+
* What renders the pages, instead of react-dom 18/19: the value a renderer package's function
|
|
667
|
+
* returns. Experimental: the renderer interface may change between versions.
|
|
668
|
+
*/
|
|
669
|
+
renderer?: RendererDescriptor
|
|
670
|
+
/** Redirect `require("gatsby/...")` of Node plugins to goatly (default: true). */
|
|
671
|
+
gatsbyModuleAlias?: boolean
|
|
672
|
+
/**
|
|
673
|
+
* The declaration file that types `graphql()` queries and `QueryResult<"Name">` with gql.tada,
|
|
674
|
+
* written when the queries are extracted, at `src/gatsby-graphql-env.d.ts`. By default for sites
|
|
675
|
+
* with a tsconfig.json that use `graphql()` calls or `QueryResult`/`QueryVariables`/
|
|
676
|
+
* `FragmentResult`; `true` generates it in any case, `false` never, `typesOutputPath` moves it.
|
|
677
|
+
*/
|
|
678
|
+
gqlTada?: boolean | { typesOutputPath?: string }
|
|
679
|
+
/**
|
|
680
|
+
* goatly: 404 pages of site sections, e.g. one per language. An unknown URL in a section
|
|
681
|
+
* gets the section's 404 page (status 404 in `develop` and `serve`, built as
|
|
682
|
+
* `<section>/404.html` too); all other unknown URLs get src/pages/404 (`/404.html`), as in Gatsby.
|
|
683
|
+
* - a list of sections: the 404 page of each is `<section>/404/`, e.g. src/pages/de/404.tsx
|
|
684
|
+
* - an object: section → its 404 page (any page, also one made with `createPage`)
|
|
685
|
+
*
|
|
686
|
+
* Sections are path prefixes without `pathPrefix`; the longest one containing the URL wins.
|
|
687
|
+
* @example notFoundPages: ["/de", "/fr"]
|
|
688
|
+
* @example notFoundPages: { "/de": "/de/404/", "/de-at": "/de/404/", "/fr": "/fr/introuvable/" }
|
|
689
|
+
*/
|
|
690
|
+
notFoundPages?: ReadonlyArray<string> | Readonly<Record<string, string>>
|
|
691
|
+
/**
|
|
692
|
+
* goatly: when `<Link>` prefetches the pages it links to; a Link's `prefetch` prop overrides it.
|
|
693
|
+
* - `"viewport"` (default, like Gatsby): the page-data and JS/CSS of linked pages once a link is
|
|
694
|
+
* visible (a few pages at a time, when the browser is idle), and the whole page on intent
|
|
695
|
+
* - `"intent"`: only on intent: hovering a link (50 ms), focusing or touching it
|
|
696
|
+
* - `false`: never (`prefetchPathname()` still prefetches)
|
|
697
|
+
*
|
|
698
|
+
* Nothing is prefetched for visitors with Save-Data or a 2G connection.
|
|
699
|
+
*/
|
|
700
|
+
prefetch?: boolean | "viewport" | "intent"
|
|
701
|
+
/**
|
|
702
|
+
* goatly: React Compiler, run with Oxc's Rust port instead of Babel (experimental; install
|
|
703
|
+
* the `oxc-transform-react` package, and `react-compiler-runtime` for React 17/18). `true` compiles
|
|
704
|
+
* the site's sources with the default options, an object sets them. Unset: on when the site's
|
|
705
|
+
* Babel config (`.babelrc`, `babel.config.*` or `setBabelPlugin`) uses
|
|
706
|
+
* `babel-plugin-react-compiler`, with its options; `false` turns it off in any case.
|
|
707
|
+
* `outputMode: "lint"` only prints React Compiler's diagnostics and leaves the code unchanged.
|
|
708
|
+
* @example reactCompiler: true
|
|
709
|
+
* @example reactCompiler: { outputMode: "lint" }
|
|
710
|
+
*/
|
|
711
|
+
reactCompiler?: boolean | ReactCompilerConfig
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Options of `reactCompiler` in gatsby-config: those of babel-plugin-react-compiler that Oxc's port has. */
|
|
715
|
+
export interface ReactCompilerConfig {
|
|
716
|
+
/** which functions are compiled (default: "infer", components and hooks) */
|
|
717
|
+
compilationMode?: "infer" | "syntax" | "annotation" | "all"
|
|
718
|
+
/** which diagnostics fail the build (default: "none": functions with errors are left as they are) */
|
|
719
|
+
panicThreshold?: "none" | "critical_errors" | "all_errors"
|
|
720
|
+
/** the React the output runs on (default: the installed `react`; 19 with another renderer) */
|
|
721
|
+
target?: "17" | "18" | "19"
|
|
722
|
+
/** compiled and original functions behind an imported feature flag */
|
|
723
|
+
gating?: { source: string; importSpecifierName: string }
|
|
724
|
+
/** where flags in `"use memo if(...)"` directives are imported from */
|
|
725
|
+
dynamicGating?: { source: string }
|
|
726
|
+
/**
|
|
727
|
+
* - `"client"` (default): compiled output in the browser and the SSR bundle
|
|
728
|
+
* - `"ssr"`: React Compiler's server output (no memoization, no event handlers or effects) in the
|
|
729
|
+
* SSR bundle, compiled output in the browser
|
|
730
|
+
* - `"lint"`: the code is left unchanged and React Compiler's diagnostics are printed
|
|
731
|
+
*/
|
|
732
|
+
outputMode?: "client" | "ssr" | "lint"
|
|
733
|
+
/** print React Compiler's diagnostics (skipped functions, rule violations); default: in lint mode */
|
|
734
|
+
reportDiagnostics?: boolean
|
|
735
|
+
/** lint rules whose suppression comments opt a function out (default: the React Hooks rules) */
|
|
736
|
+
eslintSuppressionRules?: string[]
|
|
737
|
+
flowSuppressions?: boolean
|
|
738
|
+
/** also compile functions with "use no memo" */
|
|
739
|
+
ignoreUseNoForget?: boolean
|
|
740
|
+
/** more directives that opt a function or module out */
|
|
741
|
+
customOptOutDirectives?: string[]
|
|
742
|
+
/** files to compile: substrings of their path, or a function (default: all but node_modules) */
|
|
743
|
+
sources?: ReadonlyArray<string> | ((filename: string) => boolean)
|
|
744
|
+
/** React Compiler's environment options (e.g. `validateRefAccessDuringRender`) */
|
|
745
|
+
environment?: Record<string, unknown>
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/** A renderer for the `renderer` option of gatsby-config (plain data: worker threads get it too). */
|
|
749
|
+
export interface RendererDescriptor {
|
|
750
|
+
name: string
|
|
751
|
+
/** Module whose default export creates the renderer: a package name, or a path relative to the site. */
|
|
752
|
+
module: string
|
|
753
|
+
/** Passed to that function. Must survive a structured clone. */
|
|
754
|
+
options?: unknown
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Pluggable node storage used by goatly. Gatsby hard-codes LMDB; goatly defaults to a
|
|
759
|
+
* log-structured file store and accepts any implementation of this interface via `datastore` in
|
|
760
|
+
* gatsby-config.
|
|
761
|
+
*/
|
|
762
|
+
export interface DataStore {
|
|
763
|
+
readonly name: string
|
|
764
|
+
/** shared between threads (e.g. a database file): query workers don't load a copy of all nodes */
|
|
765
|
+
readonly sharedAcrossThreads?: boolean
|
|
766
|
+
/**
|
|
767
|
+
* nodes are read on demand: the query engine keeps node ids instead of node objects in its caches
|
|
768
|
+
* and never loads all nodes at once (object identity is not stable; mutated nodes are set again)
|
|
769
|
+
*/
|
|
770
|
+
readonly lazy?: boolean
|
|
771
|
+
/** node ids of a type in insertion order (lazy stores) */
|
|
772
|
+
getNodeIdsByType?(typeName: string): string[]
|
|
773
|
+
/** type of a node without loading it (lazy stores) */
|
|
774
|
+
getNodeType?(id: string): string | undefined
|
|
775
|
+
/** parent id of a node without loading it (lazy stores) */
|
|
776
|
+
getNodeParent?(id: string): string | null | undefined
|
|
777
|
+
/** highest `internal.counter` of all nodes, without loading them (restored stores) */
|
|
778
|
+
getMaxNodeCounter?(): number
|
|
779
|
+
/** `internal.contentDigest` of a node without loading it (unchanged nodes are only touched) */
|
|
780
|
+
getNodeDigest?(id: string): string | undefined
|
|
781
|
+
/** batched lookup in the order of `ids` (lazy stores) */
|
|
782
|
+
getNodesByIds?(ids: readonly string[], options?: { cache?: boolean }): Array<Node | undefined>
|
|
783
|
+
getNode(id: string): Node | undefined
|
|
784
|
+
getTypes(): string[]
|
|
785
|
+
countNodes(typeName?: string): number
|
|
786
|
+
getNodes(): Node[]
|
|
787
|
+
getNodesByType(typeName: string): Node[]
|
|
788
|
+
iterateNodes(): Iterable<Node>
|
|
789
|
+
iterateNodesByType(typeName: string): Iterable<Node>
|
|
790
|
+
setNode(node: Node, oldNode?: Node): void
|
|
791
|
+
deleteNode(node: Node): void
|
|
792
|
+
ready(): Promise<void>
|
|
793
|
+
clear(): void | Promise<void>
|
|
794
|
+
/**
|
|
795
|
+
* Drop decoded nodes kept for reuse: query workers call it when their heap fills up. What reads
|
|
796
|
+
* return must not change.
|
|
797
|
+
*/
|
|
798
|
+
trimCache?(): void
|
|
799
|
+
/** Restore persisted nodes. Required for parallel query running. */
|
|
800
|
+
load?(): Promise<boolean>
|
|
801
|
+
/** Persist nodes. Required for parallel query running. */
|
|
802
|
+
persist?(): Promise<void>
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Gatsby API for Node.js.
|
|
807
|
+
*
|
|
808
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/
|
|
809
|
+
*/
|
|
810
|
+
export interface GatsbyNode<
|
|
811
|
+
TNode extends Record<string, unknown> = Record<string, unknown>,
|
|
812
|
+
TContext = Record<string, unknown>,
|
|
813
|
+
> {
|
|
814
|
+
/**
|
|
815
|
+
* Tell plugins to add pages. This extension point is called only after the initial
|
|
816
|
+
* sourcing and transformation of nodes plus creation of the GraphQL schema are
|
|
817
|
+
* complete so you can query your data in order to create pages.
|
|
818
|
+
*
|
|
819
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/#createPages
|
|
820
|
+
*/
|
|
821
|
+
createPages?(
|
|
822
|
+
args: CreatePagesArgs & {
|
|
823
|
+
traceId: "initial-createPages"
|
|
824
|
+
},
|
|
825
|
+
options: PluginOptions,
|
|
826
|
+
callback: PluginCallback<void>,
|
|
827
|
+
): void | Promise<void>
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Like `createPages` but for plugins who want to manage creating and removing
|
|
831
|
+
* pages themselves in response to changes in data *not* managed by Gatsby.
|
|
832
|
+
* Plugins implementing `createPages` will get called regularly to recompute
|
|
833
|
+
* page information as Gatsby's data changes but those implementing
|
|
834
|
+
* `createPagesStatefully` will not.
|
|
835
|
+
*
|
|
836
|
+
* An example of a plugin that uses this extension point is the plugin
|
|
837
|
+
* [gatsby-plugin-page-creator](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-page-creator)
|
|
838
|
+
* which monitors the `src/pages` directory for the adding and removal of JS
|
|
839
|
+
* pages. As its source of truth, files in the pages directory, is not known by
|
|
840
|
+
* Gatsby, it needs to keep its own state about its world to know when to
|
|
841
|
+
* add and remove pages.
|
|
842
|
+
*/
|
|
843
|
+
createPagesStatefully?(
|
|
844
|
+
args: CreatePagesArgs & {
|
|
845
|
+
traceId: "initial-createPagesStatefully"
|
|
846
|
+
},
|
|
847
|
+
options: PluginOptions,
|
|
848
|
+
callback: PluginCallback<void>,
|
|
849
|
+
): void | Promise<void>
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Let plugins extend/mutate the site's Babel configuration.
|
|
853
|
+
* This API will change before 2.0 as it needs still to be converted to use
|
|
854
|
+
* Redux actions.
|
|
855
|
+
*/
|
|
856
|
+
onCreateBabelConfig?(
|
|
857
|
+
args: CreateBabelConfigArgs,
|
|
858
|
+
options: PluginOptions,
|
|
859
|
+
callback: PluginCallback<void>,
|
|
860
|
+
): void | Promise<void>
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Run when gatsby develop server is started, its useful to add proxy and middleware
|
|
864
|
+
* to the dev server app
|
|
865
|
+
* @param {object} $0
|
|
866
|
+
* @param {Express} $0.app The [Express app](https://expressjs.com/en/4x/api.html#app) used to run the dev server
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
*
|
|
870
|
+
* exports.onCreateDevServer = ({ app }) => {
|
|
871
|
+
* app.get('/hello', function (req, res) {
|
|
872
|
+
* res.send('hello world')
|
|
873
|
+
* })
|
|
874
|
+
* }
|
|
875
|
+
*/
|
|
876
|
+
onCreateDevServer?(
|
|
877
|
+
args: CreateDevServerArgs,
|
|
878
|
+
options: PluginOptions,
|
|
879
|
+
calllback: PluginCallback<void>,
|
|
880
|
+
): void | Promise<void>
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Called when a new node is created. Plugins wishing to extend or
|
|
884
|
+
* transform nodes created by other plugins should implement this API.
|
|
885
|
+
*
|
|
886
|
+
* See also the documentation for `createNode`
|
|
887
|
+
* and [`createNodeField`](https://www.gatsbyjs.com/docs/reference/config-files/actions/#createNodeField)
|
|
888
|
+
* @param {object} $0
|
|
889
|
+
* @param {object} $0.node A node object.
|
|
890
|
+
* @param {object} $0.actions
|
|
891
|
+
* @param {function} $0.actions.createNode Create a new node.
|
|
892
|
+
* @param {function} $0.actions.createNodeField Extend another node. The new node field is placed under the fields key on the extended node object.
|
|
893
|
+
* @example
|
|
894
|
+
* exports.onCreateNode = ({ node, getNode, actions }) => {
|
|
895
|
+
* const { createNodeField } = actions
|
|
896
|
+
*
|
|
897
|
+
* if (node.internal.type === `MarkdownRemark`) {
|
|
898
|
+
* const nodePath = node.fileAbsolutePath
|
|
899
|
+
*
|
|
900
|
+
* if (nodePath.match(/\/blog\//)) {
|
|
901
|
+
* const postSlug = createFilePath({
|
|
902
|
+
* node,
|
|
903
|
+
* getNode,
|
|
904
|
+
* basePath: `src/content`,
|
|
905
|
+
* trailingSlash: true,
|
|
906
|
+
* })
|
|
907
|
+
*
|
|
908
|
+
* createNodeField({
|
|
909
|
+
* node,
|
|
910
|
+
* name: `slug`,
|
|
911
|
+
* value: `/blog/${postSlug}/`,
|
|
912
|
+
* })
|
|
913
|
+
* }
|
|
914
|
+
* }
|
|
915
|
+
* }
|
|
916
|
+
*/
|
|
917
|
+
onCreateNode?(
|
|
918
|
+
args: CreateNodeArgs<TNode>,
|
|
919
|
+
options: PluginOptions,
|
|
920
|
+
callback: PluginCallback<void>,
|
|
921
|
+
): void | Promise<void>
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Called before scheduling a `onCreateNode` callback for a plugin. If it returns falsy
|
|
925
|
+
* then Gatsby will not schedule the `onCreateNode` callback for this node for this plugin.
|
|
926
|
+
* Note: this API does not receive the regular `api` that other callbacks get as first arg.
|
|
927
|
+
*
|
|
928
|
+
* @gatsbyVersion 2.24.80
|
|
929
|
+
* @example
|
|
930
|
+
* exports.shouldOnCreateNode = ({node}, pluginOptions) => node.internal.type === 'Image'
|
|
931
|
+
*/
|
|
932
|
+
shouldOnCreateNode?(args: { node: TNode }, options: PluginOptions): boolean
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Called when a new page is created. This extension API is useful
|
|
936
|
+
* for programmatically manipulating pages created by other plugins e.g.
|
|
937
|
+
* if you want paths without trailing slashes.
|
|
938
|
+
*
|
|
939
|
+
* See the guide [Creating and Modifying Pages](https://www.gatsbyjs.com/docs/creating-and-modifying-pages/)
|
|
940
|
+
* for more on this API.
|
|
941
|
+
*/
|
|
942
|
+
onCreatePage?(
|
|
943
|
+
args: CreatePageArgs<TContext>,
|
|
944
|
+
options: PluginOptions,
|
|
945
|
+
callback: PluginCallback<void>,
|
|
946
|
+
): void | Promise<void>
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Let plugins extend/mutate the site's webpack configuration.
|
|
950
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/#onCreateWebpackConfig
|
|
951
|
+
*/
|
|
952
|
+
onCreateWebpackConfig?(
|
|
953
|
+
args: CreateWebpackConfigArgs,
|
|
954
|
+
options: PluginOptions,
|
|
955
|
+
callback: PluginCallback<void>,
|
|
956
|
+
): void | Promise<void>
|
|
957
|
+
|
|
958
|
+
/** Called at the end of the bootstrap process after all other extension APIs have been called. */
|
|
959
|
+
onPostBootstrap?(
|
|
960
|
+
args: ParentSpanPluginArgs,
|
|
961
|
+
options: PluginOptions,
|
|
962
|
+
callback: PluginCallback<void>,
|
|
963
|
+
): void | Promise<void>
|
|
964
|
+
|
|
965
|
+
/** The last extension point called after all other parts of the build process are complete. */
|
|
966
|
+
onPostBuild?(
|
|
967
|
+
args: BuildArgs,
|
|
968
|
+
options: PluginOptions,
|
|
969
|
+
callback: PluginCallback<void>,
|
|
970
|
+
): void | Promise<void>
|
|
971
|
+
|
|
972
|
+
/** Called at the end of the bootstrap process after all other extension APIs have been called. If you indend to use this API in a plugin, use "onPluginInit" instead. */
|
|
973
|
+
onPreBootstrap?(
|
|
974
|
+
args: ParentSpanPluginArgs,
|
|
975
|
+
options: PluginOptions,
|
|
976
|
+
callback: PluginCallback<void>,
|
|
977
|
+
): void | Promise<void>
|
|
978
|
+
|
|
979
|
+
/** The first extension point called during the build process. Called after the bootstrap has completed but before the build steps start. */
|
|
980
|
+
onPreBuild?(
|
|
981
|
+
args: BuildArgs,
|
|
982
|
+
options: PluginOptions,
|
|
983
|
+
callback: PluginCallback<void>,
|
|
984
|
+
): void | Promise<void>
|
|
985
|
+
|
|
986
|
+
/** Called once Gatsby has initialized itself and is ready to bootstrap your site. */
|
|
987
|
+
onPreExtractQueries?(
|
|
988
|
+
args: ParentSpanPluginArgs,
|
|
989
|
+
options: PluginOptions,
|
|
990
|
+
callback: PluginCallback<void>,
|
|
991
|
+
): void | Promise<void>
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Lifecycle executed in each process (one time per process). Used to store actions, etc. for later use. Plugins should use this over other APIs like "onPreBootstrap" or "onPreInit" since onPluginInit will run in main process + all workers to support Parallel Query Running.
|
|
995
|
+
* @gatsbyVersion 3.9.0
|
|
996
|
+
* @example
|
|
997
|
+
* let createJobV2
|
|
998
|
+
* exports.onPluginInit = ({ actions }) => {
|
|
999
|
+
* // Store job creation action to use it later
|
|
1000
|
+
* createJobV2 = actions.createJobV2
|
|
1001
|
+
* }
|
|
1002
|
+
*/
|
|
1003
|
+
onPluginInit?(
|
|
1004
|
+
args: ParentSpanPluginArgs,
|
|
1005
|
+
options: PluginOptions,
|
|
1006
|
+
callback: PluginCallback<void>,
|
|
1007
|
+
): void | Promise<void>
|
|
1008
|
+
|
|
1009
|
+
/** The first API called during Gatsby execution, runs as soon as plugins are loaded, before cache initialization and bootstrap preparation. If you indend to use this API in a plugin, use "onPluginInit" instead. */
|
|
1010
|
+
onPreInit?(
|
|
1011
|
+
args: PreInitArgs,
|
|
1012
|
+
options: PluginOptions,
|
|
1013
|
+
callback: PluginCallback<void>,
|
|
1014
|
+
): void | Promise<void>
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Ask compile-to-js plugins to process source to JavaScript so the query
|
|
1018
|
+
* runner can extract out GraphQL queries for running.
|
|
1019
|
+
*/
|
|
1020
|
+
preprocessSource?(
|
|
1021
|
+
args: PreprocessSourceArgs,
|
|
1022
|
+
options: PluginOptions,
|
|
1023
|
+
callback: PluginCallback<void>,
|
|
1024
|
+
): void | string | Promise<void | string>
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Lets plugins implementing support for other compile-to-js add to the list of "resolvable" file extensions. Gatsby supports `.js` and `.jsx` by default.
|
|
1028
|
+
*/
|
|
1029
|
+
resolvableExtensions?(
|
|
1030
|
+
args: ResolvableExtensionsArgs,
|
|
1031
|
+
options: PluginOptions,
|
|
1032
|
+
callback: PluginCallback<Array<string>>,
|
|
1033
|
+
): Array<string> | Promise<Array<string>>
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Called during the creation of the GraphQL schema. Allows plugins
|
|
1037
|
+
* to add new fields to the types created from data nodes. It will be called
|
|
1038
|
+
* separately for each type.
|
|
1039
|
+
*
|
|
1040
|
+
* This function should return an object in the shape of
|
|
1041
|
+
* [GraphQLFieldConfigMap](https://graphql.org/graphql-js/type/#graphqlobjecttype)
|
|
1042
|
+
* which will be appended to fields inferred by Gatsby from data nodes.
|
|
1043
|
+
*
|
|
1044
|
+
* *Note:* Import GraphQL types from `gatsby/graphql` and don't add the `graphql`
|
|
1045
|
+
* package to your project/plugin dependencies to avoid Schema must
|
|
1046
|
+
* contain unique named types but contains multiple types named errors.
|
|
1047
|
+
* `gatsby/graphql` exports all builtin GraphQL types as well as the `graphQLJSON`
|
|
1048
|
+
* type.
|
|
1049
|
+
*
|
|
1050
|
+
* Many transformer plugins use this to add fields that take arguments.
|
|
1051
|
+
*
|
|
1052
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/#setFieldsOnGraphQLNodeType
|
|
1053
|
+
*/
|
|
1054
|
+
setFieldsOnGraphQLNodeType?(
|
|
1055
|
+
args: SetFieldsOnGraphQLNodeTypeArgs,
|
|
1056
|
+
options: PluginOptions,
|
|
1057
|
+
callback: PluginCallback<any>,
|
|
1058
|
+
): any
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Extension point to tell plugins to source nodes. This API is called during
|
|
1062
|
+
* the Gatsby bootstrap sequence. Source plugins use this hook to create nodes.
|
|
1063
|
+
* This API is called exactly once per plugin (and once for your site's
|
|
1064
|
+
* `gatsby-config.js` file). If you define this hook in `gatsby-node.js` it
|
|
1065
|
+
* will be called exactly once after all of your source plugins have finished
|
|
1066
|
+
* creating nodes.
|
|
1067
|
+
*
|
|
1068
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/#sourceNodes
|
|
1069
|
+
*/
|
|
1070
|
+
sourceNodes?(
|
|
1071
|
+
args: SourceNodesArgs,
|
|
1072
|
+
options: PluginOptions,
|
|
1073
|
+
callback: PluginCallback<void>,
|
|
1074
|
+
): void | Promise<void>
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Add custom field resolvers to the GraphQL schema.
|
|
1078
|
+
*
|
|
1079
|
+
* Allows adding new fields to types by providing field configs, or adding resolver
|
|
1080
|
+
* functions to existing fields.
|
|
1081
|
+
*
|
|
1082
|
+
* Things to note:
|
|
1083
|
+
* * Overriding field types is disallowed, instead use the `createTypes`
|
|
1084
|
+
* action. In case of types added from third-party schemas, where this is not
|
|
1085
|
+
* possible, overriding field types is allowed.
|
|
1086
|
+
* * New fields will not be available on `filter` and `sort` input types. Extend
|
|
1087
|
+
* types defined with `createTypes` if you need this.
|
|
1088
|
+
* * In field configs, types can be referenced as strings.
|
|
1089
|
+
* * When extending a field with an existing field resolver, the original
|
|
1090
|
+
* resolver function is available from `info.originalResolver`.
|
|
1091
|
+
* * The `createResolvers` API is called as the last step in schema generation.
|
|
1092
|
+
* Thus, an intermediate schema is made available on the `schema` property.
|
|
1093
|
+
* In resolver functions themselves, it is recommended to access the final
|
|
1094
|
+
* built schema from `info.schema`.
|
|
1095
|
+
* * Gatsby's data layer, including all internal query capabilities, is
|
|
1096
|
+
* exposed on [`context.nodeModel`](/docs/node-model/). The node store can be
|
|
1097
|
+
* queried directly with `findOne`, `getNodeById` and `getNodesByIds`,
|
|
1098
|
+
* while more advanced queries can be composed with `findAll`.
|
|
1099
|
+
* * It is possible to add fields to the root `Query` type.
|
|
1100
|
+
* * When using the first resolver argument (`source` in the example below,
|
|
1101
|
+
* often also called `parent` or `root`), take care of the fact that field
|
|
1102
|
+
* resolvers can be called more than once in a query, e.g. when the field is
|
|
1103
|
+
* present both in the input filter and in the selection set. This means that
|
|
1104
|
+
* foreign-key fields on `source` can be either resolved or not-resolved.
|
|
1105
|
+
*
|
|
1106
|
+
* For fuller examples, see [`using-type-definitions`](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-type-definitions).
|
|
1107
|
+
*
|
|
1108
|
+
* @see https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/#createResolvers
|
|
1109
|
+
*/
|
|
1110
|
+
createResolvers?(
|
|
1111
|
+
args: CreateResolversArgs,
|
|
1112
|
+
options: PluginOptions,
|
|
1113
|
+
callback: PluginCallback<void>,
|
|
1114
|
+
): void | Promise<void>
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Customize Gatsby’s GraphQL schema by creating type definitions, field extensions or adding third-party schemas.
|
|
1118
|
+
* The createTypes, createFieldExtension and addThirdPartySchema actions are only available in this API.
|
|
1119
|
+
*
|
|
1120
|
+
* For details on their usage please refer to the actions documentation.
|
|
1121
|
+
*
|
|
1122
|
+
* This API runs immediately before schema generation. For modifications of the generated schema, e.g.
|
|
1123
|
+
* to customize added third-party types, use the createResolvers API.
|
|
1124
|
+
* @see https://www.gatsbyjs.com/docs/node-apis/#createSchemaCustomization
|
|
1125
|
+
*/
|
|
1126
|
+
createSchemaCustomization?(
|
|
1127
|
+
args: CreateSchemaCustomizationArgs,
|
|
1128
|
+
options: PluginOptions,
|
|
1129
|
+
callback: PluginCallback<void>,
|
|
1130
|
+
): void | Promise<void>
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Add a Joi schema for the possible options of your plugin.
|
|
1134
|
+
* Currently experimental and not enabled by default.
|
|
1135
|
+
*/
|
|
1136
|
+
pluginOptionsSchema?(args: PluginOptionsSchemaArgs): ObjectSchema
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* goatly: extend the generated Vite configuration. Return a partial config that is merged
|
|
1140
|
+
* with Vite's `mergeConfig`. (`onCreateWebpackConfig` keeps working for aliases and DefinePlugin values.)
|
|
1141
|
+
*/
|
|
1142
|
+
onCreateViteConfig?(
|
|
1143
|
+
args: ParentSpanPluginArgs & { stage: GatsbyStages; getConfig: () => Record<string, any> },
|
|
1144
|
+
options: PluginOptions,
|
|
1145
|
+
): Record<string, any> | void | Promise<Record<string, any> | void>
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Gatsby browser API.
|
|
1150
|
+
*
|
|
1151
|
+
* @see https://www.gatsbyjs.com/docs/browser-apis/
|
|
1152
|
+
*/
|
|
1153
|
+
export interface GatsbyBrowser<
|
|
1154
|
+
DataType = Record<string, unknown>,
|
|
1155
|
+
PageContext = Record<string, unknown>,
|
|
1156
|
+
LocationState = WindowLocation["state"],
|
|
1157
|
+
> {
|
|
1158
|
+
disableCorePrefetching?(args: BrowserPluginArgs, options: PluginOptions): boolean
|
|
1159
|
+
/**
|
|
1160
|
+
* An error boundary caught an error (Gatsby 5.16, React 19's `onCaughtError` root option; not
|
|
1161
|
+
* called with React 18). React does not log the error itself once a plugin implements this.
|
|
1162
|
+
*/
|
|
1163
|
+
onCaughtError?(args: RootErrorArgs, options: PluginOptions): void
|
|
1164
|
+
onClientEntry?(args: BrowserPluginArgs, options: PluginOptions): void
|
|
1165
|
+
onInitialClientRender?(args: BrowserPluginArgs, options: PluginOptions): void
|
|
1166
|
+
onPostPrefetchPathname?(args: PrefetchPathnameArgs, options: PluginOptions): void
|
|
1167
|
+
onPreRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): void
|
|
1168
|
+
onPrefetchPathname?(args: PrefetchPathnameArgs, options: PluginOptions): void
|
|
1169
|
+
onRouteUpdate?(args: RouteUpdateArgs, options: PluginOptions): void
|
|
1170
|
+
onRouteUpdateDelayed?(args: RouteUpdateDelayedArgs, options: PluginOptions): void
|
|
1171
|
+
onServiceWorkerActive?(args: ServiceWorkerArgs, options: PluginOptions): void
|
|
1172
|
+
onServiceWorkerInstalled?(args: ServiceWorkerArgs, options: PluginOptions): void
|
|
1173
|
+
onServiceWorkerRedundant?(args: ServiceWorkerArgs, options: PluginOptions): void
|
|
1174
|
+
onServiceWorkerUpdateFound?(args: ServiceWorkerArgs, options: PluginOptions): void
|
|
1175
|
+
onServiceWorkerUpdateReady?(args: ServiceWorkerArgs, options: PluginOptions): void
|
|
1176
|
+
/**
|
|
1177
|
+
* No error boundary caught an error and React unmounted the app (Gatsby 5.16, React 19's
|
|
1178
|
+
* `onUncaughtError` root option; not called with React 18). The error is logged with
|
|
1179
|
+
* `console.error` instead of being reported to `window.onerror` once a plugin implements this.
|
|
1180
|
+
*/
|
|
1181
|
+
onUncaughtError?(args: RootErrorArgs, options: PluginOptions): void
|
|
1182
|
+
registerServiceWorker?(args: BrowserPluginArgs, options: PluginOptions): boolean
|
|
1183
|
+
replaceHydrateFunction?(args: BrowserPluginArgs, options: PluginOptions): Renderer
|
|
1184
|
+
shouldUpdateScroll?(
|
|
1185
|
+
args: ShouldUpdateScrollArgs,
|
|
1186
|
+
options: PluginOptions,
|
|
1187
|
+
): boolean | [number, number] | string
|
|
1188
|
+
wrapPageElement?(
|
|
1189
|
+
args: WrapPageElementBrowserArgs<DataType, PageContext, LocationState>,
|
|
1190
|
+
options: PluginOptions,
|
|
1191
|
+
): React.ReactElement
|
|
1192
|
+
wrapRootElement?(args: WrapRootElementBrowserArgs, options: PluginOptions): React.ReactElement
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Gatsby server-side rendering API.
|
|
1197
|
+
*
|
|
1198
|
+
* @see https://www.gatsbyjs.com/docs/ssr-apis/
|
|
1199
|
+
*/
|
|
1200
|
+
export interface GatsbySSR<
|
|
1201
|
+
DataSet = Record<string, unknown>,
|
|
1202
|
+
PageContext = Record<string, unknown>,
|
|
1203
|
+
> {
|
|
1204
|
+
/**
|
|
1205
|
+
* Called after every page Gatsby server renders while building HTML so you can
|
|
1206
|
+
* replace head components to be rendered in your `html.js`. This is useful if
|
|
1207
|
+
* you need to reorder scripts or styles added by other plugins.
|
|
1208
|
+
* @example
|
|
1209
|
+
* // Move Typography.js styles to the top of the head section so they're loaded first.
|
|
1210
|
+
* exports.onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => {
|
|
1211
|
+
* const headComponents = getHeadComponents()
|
|
1212
|
+
* headComponents.sort((x, y) => {
|
|
1213
|
+
* if (x.key === 'TypographyStyle') {
|
|
1214
|
+
* return -1
|
|
1215
|
+
* } else if (y.key === 'TypographyStyle') {
|
|
1216
|
+
* return 1
|
|
1217
|
+
* }
|
|
1218
|
+
* return 0
|
|
1219
|
+
* })
|
|
1220
|
+
* replaceHeadComponents(headComponents)
|
|
1221
|
+
* }
|
|
1222
|
+
*/
|
|
1223
|
+
onPreRenderHTML?(args: PreRenderHTMLArgs, options: PluginOptions): void
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Called after every page Gatsby server renders while building HTML so you can
|
|
1227
|
+
* set head and body components to be rendered in your `html.js`.
|
|
1228
|
+
*
|
|
1229
|
+
* Gatsby does a two-pass render for HTML. It loops through your pages first
|
|
1230
|
+
* rendering only the body and then takes the result body HTML string and
|
|
1231
|
+
* passes it as the `body` prop to your `html.js` to complete the render.
|
|
1232
|
+
*
|
|
1233
|
+
* It's often handy to be able to send custom components to your `html.js`.
|
|
1234
|
+
* For example, it's a very common pattern for React.js libraries that
|
|
1235
|
+
* support server rendering to pull out data generated during the render to
|
|
1236
|
+
* add to your HTML.
|
|
1237
|
+
*
|
|
1238
|
+
* Using this API over `replaceRenderer` is preferable as
|
|
1239
|
+
* multiple plugins can implement this API where only one plugin can take
|
|
1240
|
+
* over server rendering. However, if your plugin requires taking over server
|
|
1241
|
+
* rendering then that's the one to use
|
|
1242
|
+
* @example
|
|
1243
|
+
* const { Helmet } = require("react-helmet")
|
|
1244
|
+
*
|
|
1245
|
+
* exports.onRenderBody = (
|
|
1246
|
+
* { setHeadComponents, setHtmlAttributes, setBodyAttributes },
|
|
1247
|
+
* pluginOptions
|
|
1248
|
+
* ) => {
|
|
1249
|
+
* const helmet = Helmet.renderStatic()
|
|
1250
|
+
* setHtmlAttributes(helmet.htmlAttributes.toComponent())
|
|
1251
|
+
* setBodyAttributes(helmet.bodyAttributes.toComponent())
|
|
1252
|
+
* setHeadComponents([
|
|
1253
|
+
* helmet.title.toComponent(),
|
|
1254
|
+
* helmet.link.toComponent(),
|
|
1255
|
+
* helmet.meta.toComponent(),
|
|
1256
|
+
* helmet.noscript.toComponent(),
|
|
1257
|
+
* helmet.script.toComponent(),
|
|
1258
|
+
* helmet.style.toComponent(),
|
|
1259
|
+
* ])
|
|
1260
|
+
* }
|
|
1261
|
+
*/
|
|
1262
|
+
onRenderBody?(args: RenderBodyArgs, options: PluginOptions): void
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Replace the default server renderer. This is useful for integration with
|
|
1266
|
+
* Redux, css-in-js libraries, etc. that need custom setups for server
|
|
1267
|
+
* rendering.
|
|
1268
|
+
* @example
|
|
1269
|
+
* // From gatsby-plugin-glamor
|
|
1270
|
+
* const { renderToString } = require("react-dom/server")
|
|
1271
|
+
* const inline = require("glamor-inline")
|
|
1272
|
+
*
|
|
1273
|
+
* exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
|
|
1274
|
+
* const bodyHTML = renderToString(bodyComponent)
|
|
1275
|
+
* const inlinedHTML = inline(bodyHTML)
|
|
1276
|
+
*
|
|
1277
|
+
* replaceBodyHTMLString(inlinedHTML)
|
|
1278
|
+
* }
|
|
1279
|
+
*/
|
|
1280
|
+
replaceRenderer?(args: ReplaceRendererArgs, options: PluginOptions): void | Promise<void>
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Allow a plugin to wrap the page element.
|
|
1284
|
+
*
|
|
1285
|
+
* This is useful for setting wrapper component around pages that won't get
|
|
1286
|
+
* unmounted on page change. For setting Provider components use `wrapRootElement`.
|
|
1287
|
+
*
|
|
1288
|
+
* _Note:_ [There is equivalent hook in Browser API](https://www.gatsbyjs.com/docs/browser-apis/#wrapPageElement)
|
|
1289
|
+
* @example
|
|
1290
|
+
* const React = require("react")
|
|
1291
|
+
* const Layout = require("./src/components/layout")
|
|
1292
|
+
*
|
|
1293
|
+
* exports.wrapPageElement = ({ element, props }) => {
|
|
1294
|
+
* // props provide same data to Layout as Page element will get
|
|
1295
|
+
* // including location, data, etc - you don't need to pass it
|
|
1296
|
+
* return <Layout {...props}>{element}</Layout>
|
|
1297
|
+
* }
|
|
1298
|
+
*/
|
|
1299
|
+
wrapPageElement?(
|
|
1300
|
+
args: WrapPageElementNodeArgs<DataSet, PageContext>,
|
|
1301
|
+
options: PluginOptions,
|
|
1302
|
+
): React.ReactElement
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Allow a plugin to wrap the root element.
|
|
1306
|
+
*
|
|
1307
|
+
* This is useful to setup any Providers component that will wrap your application.
|
|
1308
|
+
* For setting persistent UI elements around pages use `wrapPageElement`.
|
|
1309
|
+
*
|
|
1310
|
+
* _Note:_ [There is equivalent hook in Browser API](https://www.gatsbyjs.com/docs/browser-apis/#wrapRootElement)
|
|
1311
|
+
* @example
|
|
1312
|
+
* const React = require("react")
|
|
1313
|
+
* const { Provider } = require("react-redux")
|
|
1314
|
+
*
|
|
1315
|
+
* const createStore = require("./src/state/createStore")
|
|
1316
|
+
* const store = createStore()
|
|
1317
|
+
*
|
|
1318
|
+
* exports.wrapRootElement = ({ element }) => {
|
|
1319
|
+
* return (
|
|
1320
|
+
* <Provider store={store}>
|
|
1321
|
+
* {element}
|
|
1322
|
+
* </Provider>
|
|
1323
|
+
* )
|
|
1324
|
+
* }
|
|
1325
|
+
*/
|
|
1326
|
+
wrapRootElement?(args: WrapRootElementNodeArgs, options: PluginOptions): React.ReactElement
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
export interface PluginOptions {
|
|
1330
|
+
plugins: unknown[]
|
|
1331
|
+
[key: string]: unknown
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
export type PluginCallback<R = any> = (err: Error | null, result?: R) => void
|
|
1335
|
+
|
|
1336
|
+
export interface CreatePagesArgs extends ParentSpanPluginArgs {
|
|
1337
|
+
/**
|
|
1338
|
+
* The type of `data` follows from a query string literal (once the GraphQL types are generated),
|
|
1339
|
+
* or is given as `TData` (or by the type the result is assigned to, as in Gatsby).
|
|
1340
|
+
*/
|
|
1341
|
+
graphql<
|
|
1342
|
+
Query extends (HasGraphQLTypes extends true ? `${string}{${string}` : never),
|
|
1343
|
+
TData = NodeQueryData<Query>,
|
|
1344
|
+
>(
|
|
1345
|
+
query: Query,
|
|
1346
|
+
variables?: object,
|
|
1347
|
+
): Promise<{
|
|
1348
|
+
errors?: any
|
|
1349
|
+
data?: TData
|
|
1350
|
+
}>
|
|
1351
|
+
graphql<TData, TVariables = any>(
|
|
1352
|
+
query: string,
|
|
1353
|
+
variables?: TVariables,
|
|
1354
|
+
): Promise<{
|
|
1355
|
+
errors?: any
|
|
1356
|
+
data?: TData
|
|
1357
|
+
}>
|
|
1358
|
+
traceId: string
|
|
1359
|
+
waitForCascadingActions: boolean
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
type GatsbyStages = "develop" | "develop-html" | "build-javascript" | "build-html"
|
|
1363
|
+
|
|
1364
|
+
export interface CreateBabelConfigArgs extends ParentSpanPluginArgs {
|
|
1365
|
+
stage: GatsbyStages
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
export interface CreateDevServerArgs extends ParentSpanPluginArgs {
|
|
1369
|
+
app: any
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
export interface CreateNodeArgs<
|
|
1373
|
+
TNode extends Record<string, unknown> = Record<string, unknown>,
|
|
1374
|
+
> extends ParentSpanPluginArgs {
|
|
1375
|
+
node: Node & TNode
|
|
1376
|
+
traceId: string
|
|
1377
|
+
traceTags: {
|
|
1378
|
+
nodeId: string
|
|
1379
|
+
nodeType: string
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
export interface CreatePageArgs<TContext = Record<string, unknown>> extends ParentSpanPluginArgs {
|
|
1384
|
+
page: Page<TContext>
|
|
1385
|
+
traceId: string
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
export interface CreateWebpackConfigArgs extends ParentSpanPluginArgs {
|
|
1389
|
+
getConfig: Function
|
|
1390
|
+
stage: GatsbyStages
|
|
1391
|
+
rules: WebpackRules
|
|
1392
|
+
loaders: WebpackLoaders
|
|
1393
|
+
plugins: WebpackPlugins
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
export interface PreprocessSourceArgs extends ParentSpanPluginArgs {
|
|
1397
|
+
filename: string
|
|
1398
|
+
contents: string
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
export interface ResolvableExtensionsArgs extends ParentSpanPluginArgs {
|
|
1402
|
+
traceId: "initial-resolvableExtensions"
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
export interface SetFieldsOnGraphQLNodeTypeArgs extends ParentSpanPluginArgs {
|
|
1406
|
+
type: {
|
|
1407
|
+
name: string
|
|
1408
|
+
nodes: any[]
|
|
1409
|
+
}
|
|
1410
|
+
traceId: "initial-setFieldsOnGraphQLNodeType"
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
export interface GatsbyGraphQLObjectType {
|
|
1414
|
+
kind: "OBJECT"
|
|
1415
|
+
config: ComposeObjectTypeConfig<any, any>
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
export interface GatsbyGraphQLInputObjectType {
|
|
1419
|
+
kind: "INPUT_OBJECT"
|
|
1420
|
+
config: ComposeInputObjectTypeConfig
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
export interface GatsbyGraphQLUnionType {
|
|
1424
|
+
kind: "UNION"
|
|
1425
|
+
config: ComposeUnionTypeConfig<any, any>
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
export interface GatsbyGraphQLInterfaceType {
|
|
1429
|
+
kind: "INTERFACE"
|
|
1430
|
+
config: ComposeInterfaceTypeConfig<any, any>
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
export interface GatsbyGraphQLEnumType {
|
|
1434
|
+
kind: "ENUM"
|
|
1435
|
+
config: ComposeEnumTypeConfig
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
export interface GatsbyGraphQLScalarType {
|
|
1439
|
+
kind: "SCALAR"
|
|
1440
|
+
config: ComposeScalarTypeConfig
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
export type GatsbyGraphQLType =
|
|
1444
|
+
| GatsbyGraphQLObjectType
|
|
1445
|
+
| GatsbyGraphQLInputObjectType
|
|
1446
|
+
| GatsbyGraphQLUnionType
|
|
1447
|
+
| GatsbyGraphQLInterfaceType
|
|
1448
|
+
| GatsbyGraphQLEnumType
|
|
1449
|
+
| GatsbyGraphQLScalarType
|
|
1450
|
+
|
|
1451
|
+
export interface NodePluginSchema {
|
|
1452
|
+
buildObjectType(config: ComposeObjectTypeConfig<any, any>): GatsbyGraphQLObjectType
|
|
1453
|
+
buildUnionType(config: ComposeUnionTypeConfig<any, any>): GatsbyGraphQLUnionType
|
|
1454
|
+
buildInterfaceType(config: ComposeInterfaceTypeConfig<any, any>): GatsbyGraphQLInterfaceType
|
|
1455
|
+
buildInputObjectType(config: ComposeInputObjectTypeConfig): GatsbyGraphQLInputObjectType
|
|
1456
|
+
buildEnumType(config: ComposeEnumTypeConfig): GatsbyGraphQLEnumType
|
|
1457
|
+
buildScalarType(config: ComposeScalarTypeConfig): GatsbyGraphQLScalarType
|
|
1458
|
+
}
|
|
1459
|
+
export interface PreInitArgs extends ParentSpanPluginArgs {
|
|
1460
|
+
actions: Actions
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
export interface SourceNodesArgs extends ParentSpanPluginArgs {
|
|
1464
|
+
traceId: "initial-sourceNodes"
|
|
1465
|
+
waitForCascadingActions: boolean
|
|
1466
|
+
webhookBody: any
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
export interface CreateResolversArgs extends ParentSpanPluginArgs {
|
|
1470
|
+
intermediateSchema: object
|
|
1471
|
+
createResolvers: Function
|
|
1472
|
+
traceId: "initial-createResolvers"
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
export interface CreateSchemaCustomizationArgs extends ParentSpanPluginArgs {
|
|
1476
|
+
traceId: "initial-createSchemaCustomization"
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
export interface PreRenderHTMLArgs {
|
|
1480
|
+
getHeadComponents: () => React.ReactNode[]
|
|
1481
|
+
replaceHeadComponents: (comp: React.ReactNode[]) => void
|
|
1482
|
+
getPreBodyComponents: () => React.ReactNode[]
|
|
1483
|
+
replacePreBodyComponents: (comp: React.ReactNode[]) => void
|
|
1484
|
+
getPostBodyComponents: () => React.ReactNode[]
|
|
1485
|
+
replacePostBodyComponents: (comp: React.ReactNode[]) => void
|
|
1486
|
+
pathname: string
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
type ReactProps<T extends Element> = React.DetailedHTMLProps<React.HTMLAttributes<T>, T>
|
|
1490
|
+
export interface RenderBodyArgs {
|
|
1491
|
+
loadPageDataSync: (pathname: string) => { result: Record<string, unknown> }
|
|
1492
|
+
pathname: string
|
|
1493
|
+
setHeadComponents: (comp: React.ReactNode[]) => void
|
|
1494
|
+
setHtmlAttributes: (attr: ReactProps<HTMLHtmlElement>) => void
|
|
1495
|
+
setBodyAttributes: (attr: ReactProps<HTMLBodyElement>) => void
|
|
1496
|
+
setPreBodyComponents: (comp: React.ReactNode[]) => void
|
|
1497
|
+
setPostBodyComponents: (comp: React.ReactNode[]) => void
|
|
1498
|
+
setBodyProps: Function
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
export interface ReplaceRendererArgs {
|
|
1502
|
+
replaceBodyHTMLString: (str: string) => void
|
|
1503
|
+
bodyComponent: React.ReactNode
|
|
1504
|
+
setHeadComponents: (comp: React.ReactNode[]) => void
|
|
1505
|
+
setHtmlAttributes: (attr: ReactProps<HTMLHtmlElement>) => void
|
|
1506
|
+
setBodyAttributes: (attr: ReactProps<HTMLBodyElement>) => void
|
|
1507
|
+
setPreBodyComponents: (comp: React.ReactNode[]) => void
|
|
1508
|
+
setPostBodyComponents: (comp: React.ReactNode[]) => void
|
|
1509
|
+
setBodyProps: Function
|
|
1510
|
+
pathname: string
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
export interface WrapPageElementNodeArgs<
|
|
1514
|
+
DataType = Record<string, unknown>,
|
|
1515
|
+
PageContextType = Record<string, unknown>,
|
|
1516
|
+
> {
|
|
1517
|
+
element: React.ReactElement
|
|
1518
|
+
props: PageProps<DataType, PageContextType>
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
export interface WrapRootElementNodeArgs {
|
|
1522
|
+
element: React.ReactElement
|
|
1523
|
+
pathname: string
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
export interface ParentSpanPluginArgs extends NodePluginArgs {
|
|
1527
|
+
parentSpan: Span
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
export interface NodePluginArgs {
|
|
1531
|
+
/**
|
|
1532
|
+
* Use to prefix resources URLs. `pathPrefix` will be either empty string or
|
|
1533
|
+
* path that starts with slash and doesn't end with slash. `pathPrefix` also
|
|
1534
|
+
* becomes `<assetPrefix>/<pathPrefix>` when you pass both `assetPrefix` and
|
|
1535
|
+
* `pathPrefix` in your `gatsby-config.js`.
|
|
1536
|
+
*
|
|
1537
|
+
* See [Adding a Path Prefix](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)
|
|
1538
|
+
* page for details about path prefixing.
|
|
1539
|
+
*/
|
|
1540
|
+
pathPrefix: string
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* This is the same as `pathPrefix` passed in `gatsby-config.js`.
|
|
1544
|
+
* It's an empty string if you don't pass `pathPrefix`.
|
|
1545
|
+
* When using assetPrefix, you can use this instead of pathPrefix to recieve the string you set in `gatsby-config.js`.
|
|
1546
|
+
* It won't include the `assetPrefix`.
|
|
1547
|
+
*/
|
|
1548
|
+
basePath: string
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Collection of functions used to programmatically modify Gatsby’s internal state.
|
|
1552
|
+
*/
|
|
1553
|
+
actions: Actions
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Get content for a node from the plugin that created it.
|
|
1557
|
+
*
|
|
1558
|
+
* @example
|
|
1559
|
+
* module.exports = async function onCreateNode(
|
|
1560
|
+
* { node, loadNodeContent, actions, createNodeId }
|
|
1561
|
+
* ) {
|
|
1562
|
+
* if (node.internal.mediaType === 'text/markdown') {
|
|
1563
|
+
* const { createNode, createParentChildLink } = actions
|
|
1564
|
+
* const textContent = await loadNodeContent(node)
|
|
1565
|
+
* // process textContent and create child nodes
|
|
1566
|
+
* }
|
|
1567
|
+
* }
|
|
1568
|
+
*/
|
|
1569
|
+
loadNodeContent(this: void, node: Node): Promise<string>
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* Internal redux state used for application state. Do not use, unless you
|
|
1573
|
+
* absolutely must. Store is considered a private API and can change with
|
|
1574
|
+
* any version.
|
|
1575
|
+
*/
|
|
1576
|
+
store: Store
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Internal event emitter / listener. Do not use, unless you absolutely
|
|
1580
|
+
* must. Emitter is considered a private API and can change with any version.
|
|
1581
|
+
*/
|
|
1582
|
+
emitter: EventEmitter
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Get array of all nodes.
|
|
1586
|
+
*
|
|
1587
|
+
* @returns Array of nodes.
|
|
1588
|
+
* @example
|
|
1589
|
+
* const allNodes = getNodes()
|
|
1590
|
+
*/
|
|
1591
|
+
getNodes(this: void): Node[]
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Get single node by given ID.
|
|
1595
|
+
* Don't use this in graphql resolvers - see
|
|
1596
|
+
* `getNodeAndSavePathDependency`
|
|
1597
|
+
*
|
|
1598
|
+
* @param id id of the node.
|
|
1599
|
+
* @returns Single node instance.
|
|
1600
|
+
* @example
|
|
1601
|
+
* const node = getNode(id)
|
|
1602
|
+
*/
|
|
1603
|
+
getNode(this: void, id: string): Node | undefined
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Get array of nodes of given type.
|
|
1607
|
+
* @param type Type of nodes
|
|
1608
|
+
* @returns Array of nodes.
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* const markdownNodes = getNodesByType(`MarkdownRemark`)
|
|
1612
|
+
*/
|
|
1613
|
+
getNodesByType(this: void, type: string): Node[]
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* Set of utilities to output information to user
|
|
1617
|
+
*/
|
|
1618
|
+
reporter: Reporter
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* Get single node by given ID and create dependency for given path.
|
|
1622
|
+
* This should be used instead of `getNode` in graphql resolvers to enable
|
|
1623
|
+
* tracking dependencies for query results. If it's not used Gatsby will
|
|
1624
|
+
* not rerun query if node changes leading to stale query results. See
|
|
1625
|
+
* [Page -> Node Dependency Tracking](/docs/page-node-dependencies/)
|
|
1626
|
+
* for more details.
|
|
1627
|
+
* @param id id of the node.
|
|
1628
|
+
* @param path of the node.
|
|
1629
|
+
* @returns Single node instance.
|
|
1630
|
+
*/
|
|
1631
|
+
getNodeAndSavePathDependency(this: void, id: string, path: string): Node
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Key-value store used to persist results of time/memory/cpu intensive
|
|
1635
|
+
* tasks. All functions are async and return promises.
|
|
1636
|
+
*/
|
|
1637
|
+
cache: GatsbyCache
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Get cache instance by name - this should only be used by plugins that accept subplugins.
|
|
1641
|
+
* @param id id of the node
|
|
1642
|
+
* @returns See [cache](https://www.gatsbyjs.com/docs/reference/config-files/node-api-helpers/#cache) section for reference.
|
|
1643
|
+
*/
|
|
1644
|
+
getCache(this: void, id: string): GatsbyCache
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Utility function useful to generate globally unique and stable node IDs.
|
|
1648
|
+
* It will generate different IDs for different plugins if they use same
|
|
1649
|
+
* input.
|
|
1650
|
+
*
|
|
1651
|
+
* @returns UUIDv5 ID string
|
|
1652
|
+
* @example
|
|
1653
|
+
* const node = {
|
|
1654
|
+
* id: createNodeId(`${backendData.type}${backendData.id}`),
|
|
1655
|
+
* ...restOfNodeData
|
|
1656
|
+
* }
|
|
1657
|
+
*/
|
|
1658
|
+
createNodeId(this: void, input: string): string
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Create a stable content digest from a string or object, you can use the
|
|
1662
|
+
* result of this function to set the `internal.contentDigest` field
|
|
1663
|
+
* on nodes. Gatsby uses the value of this field to invalidate stale data
|
|
1664
|
+
* when your content changes.
|
|
1665
|
+
* @param input
|
|
1666
|
+
* @returns Hash string
|
|
1667
|
+
* @example
|
|
1668
|
+
* const node = {
|
|
1669
|
+
* ...nodeData,
|
|
1670
|
+
* internal: {
|
|
1671
|
+
* type: `TypeOfNode`,
|
|
1672
|
+
* contentDigest: createContentDigest(nodeData)
|
|
1673
|
+
* }
|
|
1674
|
+
* }
|
|
1675
|
+
*/
|
|
1676
|
+
createContentDigest(this: void, input: string | object): string
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* Set of utilities that allow adding more detailed tracing for plugins.
|
|
1680
|
+
* Check
|
|
1681
|
+
* [Performance tracing](https://www.gatsbyjs.com/docs/performance-tracing)
|
|
1682
|
+
* page for more details.
|
|
1683
|
+
*/
|
|
1684
|
+
tracing: Tracing
|
|
1685
|
+
schema: NodePluginSchema
|
|
1686
|
+
[key: string]: unknown
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
interface ActionPlugin {
|
|
1690
|
+
name: string
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
interface CreateNodeFieldArgs {
|
|
1694
|
+
node: Node
|
|
1695
|
+
name: string
|
|
1696
|
+
value: string
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
interface ActionOptions {
|
|
1700
|
+
[key: string]: unknown
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
export interface BuildArgs extends ParentSpanPluginArgs {
|
|
1704
|
+
/**
|
|
1705
|
+
* The type of `data` follows from a query string literal (once the GraphQL types are generated),
|
|
1706
|
+
* or is given as `TData` (or by the type the result is assigned to, as in Gatsby).
|
|
1707
|
+
*/
|
|
1708
|
+
graphql<
|
|
1709
|
+
Query extends (HasGraphQLTypes extends true ? `${string}{${string}` : never),
|
|
1710
|
+
TData = NodeQueryData<Query>,
|
|
1711
|
+
>(
|
|
1712
|
+
query: Query,
|
|
1713
|
+
variables?: object,
|
|
1714
|
+
): Promise<{
|
|
1715
|
+
errors?: any
|
|
1716
|
+
data?: TData
|
|
1717
|
+
}>
|
|
1718
|
+
graphql<TData, TVariables = any>(
|
|
1719
|
+
query: string,
|
|
1720
|
+
variables?: TVariables,
|
|
1721
|
+
): Promise<{
|
|
1722
|
+
errors?: any
|
|
1723
|
+
data?: TData
|
|
1724
|
+
}>
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
export interface Actions {
|
|
1728
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#deletePage */
|
|
1729
|
+
deletePage(this: void, args: { path: string; component: string }): void
|
|
1730
|
+
|
|
1731
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createPage */
|
|
1732
|
+
createPage<TContext = Record<string, unknown>>(
|
|
1733
|
+
this: void,
|
|
1734
|
+
args: Page<TContext>,
|
|
1735
|
+
plugin?: ActionPlugin,
|
|
1736
|
+
option?: ActionOptions,
|
|
1737
|
+
): void
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* goatly does not support Slices: logs a warning and is ignored.
|
|
1741
|
+
* @see https://www.gatsbyjs.com/docs/reference/config-files/actions/#createSlice
|
|
1742
|
+
*/
|
|
1743
|
+
createSlice<TContext = Record<string, unknown>>(
|
|
1744
|
+
this: void,
|
|
1745
|
+
args: SliceInput<TContext>,
|
|
1746
|
+
plugin?: ActionPlugin,
|
|
1747
|
+
option?: ActionOptions,
|
|
1748
|
+
): void
|
|
1749
|
+
|
|
1750
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#deleteNode */
|
|
1751
|
+
deleteNode(node: NodeInput, plugin?: ActionPlugin): void
|
|
1752
|
+
|
|
1753
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createNode */
|
|
1754
|
+
createNode<TNode = Record<string, unknown>>(
|
|
1755
|
+
this: void,
|
|
1756
|
+
node: NodeInput & TNode,
|
|
1757
|
+
plugin?: ActionPlugin,
|
|
1758
|
+
options?: ActionOptions,
|
|
1759
|
+
): void | Promise<void>
|
|
1760
|
+
|
|
1761
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#touchNode */
|
|
1762
|
+
touchNode(node: NodeInput, plugin?: ActionPlugin): void
|
|
1763
|
+
|
|
1764
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createNodeField */
|
|
1765
|
+
createNodeField(
|
|
1766
|
+
this: void,
|
|
1767
|
+
args: {
|
|
1768
|
+
node: Node
|
|
1769
|
+
name?: string
|
|
1770
|
+
value: any
|
|
1771
|
+
},
|
|
1772
|
+
plugin?: ActionPlugin,
|
|
1773
|
+
options?: ActionOptions,
|
|
1774
|
+
): void
|
|
1775
|
+
|
|
1776
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createParentChildLink */
|
|
1777
|
+
createParentChildLink(
|
|
1778
|
+
this: void,
|
|
1779
|
+
args: { parent: Node; child: NodeInput },
|
|
1780
|
+
plugin?: ActionPlugin,
|
|
1781
|
+
): void
|
|
1782
|
+
|
|
1783
|
+
/** @see https://www.gatsbyjs.com/docs/reference/config-files/actions/#unstable_createNodeManifest */
|
|
1784
|
+
unstable_createNodeManifest(
|
|
1785
|
+
this: void,
|
|
1786
|
+
args: {
|
|
1787
|
+
manifestId: string
|
|
1788
|
+
node: Node
|
|
1789
|
+
updatedAtUTC?: string | number
|
|
1790
|
+
},
|
|
1791
|
+
plugin?: ActionPlugin,
|
|
1792
|
+
): void
|
|
1793
|
+
|
|
1794
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setRequestHeaders */
|
|
1795
|
+
setRequestHeaders(
|
|
1796
|
+
this: void,
|
|
1797
|
+
args: { domain: string; headers: Record<string, string> },
|
|
1798
|
+
plugin?: ActionPlugin,
|
|
1799
|
+
): void
|
|
1800
|
+
|
|
1801
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setWebpackConfig */
|
|
1802
|
+
setWebpackConfig(this: void, config: object, plugin?: ActionPlugin): void
|
|
1803
|
+
|
|
1804
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#replaceWebpackConfig */
|
|
1805
|
+
replaceWebpackConfig(this: void, config: object, plugin?: ActionPlugin): void
|
|
1806
|
+
|
|
1807
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setBabelOptions */
|
|
1808
|
+
setBabelOptions(this: void, options: object, plugin?: ActionPlugin): void
|
|
1809
|
+
|
|
1810
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setBabelPlugin */
|
|
1811
|
+
setBabelPlugin(this: void, config: { name: string; options: object }, plugin?: ActionPlugin): void
|
|
1812
|
+
|
|
1813
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setBabelPreset */
|
|
1814
|
+
setBabelPreset(this: void, config: { name: string; options: object }, plugin?: ActionPlugin): void
|
|
1815
|
+
|
|
1816
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createJob */
|
|
1817
|
+
createJob(this: void, job: Record<string, unknown> & { id: string }, plugin?: ActionPlugin): void
|
|
1818
|
+
|
|
1819
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createJobV2 */
|
|
1820
|
+
createJobV2(
|
|
1821
|
+
this: void,
|
|
1822
|
+
job: {
|
|
1823
|
+
name: string
|
|
1824
|
+
inputPaths: string[]
|
|
1825
|
+
outputDir: string
|
|
1826
|
+
args: Record<string, unknown>
|
|
1827
|
+
},
|
|
1828
|
+
plugin?: ActionPlugin,
|
|
1829
|
+
): Promise<unknown>
|
|
1830
|
+
|
|
1831
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#addGatsbyImageSourceUrl */
|
|
1832
|
+
addGatsbyImageSourceUrl(this: void, sourceUrl: string): void
|
|
1833
|
+
|
|
1834
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setJob */
|
|
1835
|
+
setJob(this: void, job: Record<string, unknown> & { id: string }, plugin?: ActionPlugin): void
|
|
1836
|
+
|
|
1837
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#endJob */
|
|
1838
|
+
endJob(this: void, job: { id: string }, plugin?: ActionPlugin): void
|
|
1839
|
+
|
|
1840
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#setPluginStatus */
|
|
1841
|
+
setPluginStatus(this: void, status: Record<string, unknown>, plugin?: ActionPlugin): void
|
|
1842
|
+
|
|
1843
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createRedirect */
|
|
1844
|
+
createRedirect(
|
|
1845
|
+
this: void,
|
|
1846
|
+
redirect: {
|
|
1847
|
+
fromPath: string
|
|
1848
|
+
isPermanent?: boolean
|
|
1849
|
+
toPath: string
|
|
1850
|
+
redirectInBrowser?: boolean
|
|
1851
|
+
force?: boolean
|
|
1852
|
+
statusCode?: number
|
|
1853
|
+
ignoreCase?: boolean
|
|
1854
|
+
[key: string]: unknown
|
|
1855
|
+
},
|
|
1856
|
+
plugin?: ActionPlugin,
|
|
1857
|
+
): void
|
|
1858
|
+
|
|
1859
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#addThirdPartySchema */
|
|
1860
|
+
addThirdPartySchema(
|
|
1861
|
+
this: void,
|
|
1862
|
+
args: { schema: object },
|
|
1863
|
+
plugin?: ActionPlugin,
|
|
1864
|
+
traceId?: string,
|
|
1865
|
+
): void
|
|
1866
|
+
|
|
1867
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createTypes */
|
|
1868
|
+
createTypes(
|
|
1869
|
+
this: void,
|
|
1870
|
+
types:
|
|
1871
|
+
| string
|
|
1872
|
+
| GraphQLOutputType
|
|
1873
|
+
| GatsbyGraphQLType
|
|
1874
|
+
| Array<string | GraphQLOutputType | GatsbyGraphQLType>,
|
|
1875
|
+
plugin?: ActionPlugin,
|
|
1876
|
+
traceId?: string,
|
|
1877
|
+
): void
|
|
1878
|
+
|
|
1879
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#createFieldExtension */
|
|
1880
|
+
createFieldExtension(this: void, extension: object, plugin?: ActionPlugin, traceId?: string): void
|
|
1881
|
+
|
|
1882
|
+
printTypeDefinitions(
|
|
1883
|
+
this: void,
|
|
1884
|
+
options: {
|
|
1885
|
+
path?: string
|
|
1886
|
+
include?: { types?: Array<string>; plugins?: Array<string> }
|
|
1887
|
+
exclude?: { types?: Array<string>; plugins?: Array<string> }
|
|
1888
|
+
withFieldTypes?: boolean
|
|
1889
|
+
},
|
|
1890
|
+
plugin?: ActionPlugin,
|
|
1891
|
+
traceId?: string,
|
|
1892
|
+
): void
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* Marks the source plugin that called this function as stateful. Gatsby will not check for stale nodes for any plugin that calls this.
|
|
1896
|
+
*/
|
|
1897
|
+
enableStatefulSourceNodes?(this: void, plugin?: ActionPlugin): void
|
|
1898
|
+
|
|
1899
|
+
/** @see https://www.gatsbyjs.com/docs/actions/#addRemoteFileAllowedUrl */
|
|
1900
|
+
addRemoteFileAllowedUrl?(
|
|
1901
|
+
this: void,
|
|
1902
|
+
url: string | Array<string>,
|
|
1903
|
+
plugin?: ActionPlugin,
|
|
1904
|
+
traceId?: string,
|
|
1905
|
+
): void
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
export interface Store {
|
|
1909
|
+
dispatch: Function
|
|
1910
|
+
subscribe: Function
|
|
1911
|
+
getState: Function
|
|
1912
|
+
replaceReducer: Function
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
export type ActivityTracker = {
|
|
1916
|
+
start(): () => void
|
|
1917
|
+
end(): () => void
|
|
1918
|
+
span: object
|
|
1919
|
+
setStatus(status: string): void
|
|
1920
|
+
panic: (errorMeta: string | object, error?: object) => never
|
|
1921
|
+
panicOnBuild: (errorMeta: string | object, error?: object) => void
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
export type ProgressActivityTracker = Omit<ActivityTracker, "end"> & {
|
|
1925
|
+
tick(increment?: number): void
|
|
1926
|
+
done(): void
|
|
1927
|
+
total: number
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export type ActivityArgs = {
|
|
1931
|
+
parentSpan?: object
|
|
1932
|
+
id?: string
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* @deprecated Use `GatsbyCache` instead
|
|
1937
|
+
*/
|
|
1938
|
+
export interface Cache {
|
|
1939
|
+
name: string
|
|
1940
|
+
store: {
|
|
1941
|
+
create: Function
|
|
1942
|
+
}
|
|
1943
|
+
cache: {
|
|
1944
|
+
getAndPassUp: Function
|
|
1945
|
+
wrap: Function
|
|
1946
|
+
set: Function
|
|
1947
|
+
mset: Function
|
|
1948
|
+
get: Function
|
|
1949
|
+
mget: Function
|
|
1950
|
+
del: Function
|
|
1951
|
+
reset: Function
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
export interface GatsbyCache {
|
|
1956
|
+
name: string
|
|
1957
|
+
directory: string
|
|
1958
|
+
/**
|
|
1959
|
+
* Retrieve cached value
|
|
1960
|
+
* @param key Cache key
|
|
1961
|
+
* @returns Promise resolving to cached value
|
|
1962
|
+
* @example
|
|
1963
|
+
* const value = await cache.get(`unique-key`)
|
|
1964
|
+
*/
|
|
1965
|
+
get(key: string): Promise<any>
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* Cache value
|
|
1969
|
+
* @param key Cache key
|
|
1970
|
+
* @param value Value to be cached
|
|
1971
|
+
* @returns Promise resolving to cached value
|
|
1972
|
+
* @example
|
|
1973
|
+
* await cache.set(`unique-key`, value)
|
|
1974
|
+
*/
|
|
1975
|
+
set(key: string, value: any): Promise<any>
|
|
1976
|
+
|
|
1977
|
+
/**
|
|
1978
|
+
* Deletes cached value
|
|
1979
|
+
* @param {string} key Cache key
|
|
1980
|
+
* @returns {Promise<void>} Promise resolving once key is deleted from cache
|
|
1981
|
+
* @example
|
|
1982
|
+
* await cache.del(`unique-key`)
|
|
1983
|
+
*/
|
|
1984
|
+
del(key: string): Promise<void>
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
export interface Tracing {
|
|
1988
|
+
tracer: object
|
|
1989
|
+
parentSpan: object
|
|
1990
|
+
startSpan: Function
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
export interface PackageJson {
|
|
1994
|
+
name?: string
|
|
1995
|
+
description?: string
|
|
1996
|
+
version?: string
|
|
1997
|
+
main?: string
|
|
1998
|
+
author?:
|
|
1999
|
+
| string
|
|
2000
|
+
| {
|
|
2001
|
+
name: string
|
|
2002
|
+
email: string
|
|
2003
|
+
}
|
|
2004
|
+
license?: string
|
|
2005
|
+
dependencies?: Record<string, string>
|
|
2006
|
+
devDependencies?: Record<string, string>
|
|
2007
|
+
peerDependencies?: Record<string, string>
|
|
2008
|
+
optionalDependencies?: Record<string, string>
|
|
2009
|
+
bundledDependencies?: Array<string>
|
|
2010
|
+
keywords?: string[]
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
export interface WebpackRules {
|
|
2014
|
+
js: Function
|
|
2015
|
+
mjs: Function
|
|
2016
|
+
eslint: Function
|
|
2017
|
+
yaml: Function
|
|
2018
|
+
fonts: Function
|
|
2019
|
+
images: Function
|
|
2020
|
+
media: Function
|
|
2021
|
+
miscAssets: Function
|
|
2022
|
+
css: Function
|
|
2023
|
+
cssModules: Function
|
|
2024
|
+
postcss: Function
|
|
2025
|
+
[key: string]: Function
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
export interface WebpackLoaders {
|
|
2029
|
+
json: Function
|
|
2030
|
+
yaml: Function
|
|
2031
|
+
null: Function
|
|
2032
|
+
raw: Function
|
|
2033
|
+
style: Function
|
|
2034
|
+
miniCssExtract: Function
|
|
2035
|
+
css: Function
|
|
2036
|
+
postcss: Function
|
|
2037
|
+
file: Function
|
|
2038
|
+
url: Function
|
|
2039
|
+
js: Function
|
|
2040
|
+
eslint: Function
|
|
2041
|
+
imports: Function
|
|
2042
|
+
exports: Function
|
|
2043
|
+
[key: string]: Function
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
export interface WebpackPlugins {
|
|
2047
|
+
normalModuleReplacement: Function
|
|
2048
|
+
contextReplacement: Function
|
|
2049
|
+
ignore: Function
|
|
2050
|
+
watchIgnore: Function
|
|
2051
|
+
banner: Function
|
|
2052
|
+
prefetch: Function
|
|
2053
|
+
automaticPrefetch: Function
|
|
2054
|
+
define: Function
|
|
2055
|
+
provide: Function
|
|
2056
|
+
hotModuleReplacement: Function
|
|
2057
|
+
sourceMapDevTool: Function
|
|
2058
|
+
evalSourceMapDevTool: Function
|
|
2059
|
+
evalDevToolModule: Function
|
|
2060
|
+
cache: Function
|
|
2061
|
+
extendedAPI: Function
|
|
2062
|
+
externals: Function
|
|
2063
|
+
jsonpTemplate: Function
|
|
2064
|
+
libraryTemplate: Function
|
|
2065
|
+
loaderTarget: Function
|
|
2066
|
+
memoryOutputFile: Function
|
|
2067
|
+
progress: Function
|
|
2068
|
+
setVarMainTemplate: Function
|
|
2069
|
+
umdMainTemplate: Function
|
|
2070
|
+
noErrors: Function
|
|
2071
|
+
noEmitOnErrors: Function
|
|
2072
|
+
newWatching: Function
|
|
2073
|
+
environment: Function
|
|
2074
|
+
dll: Function
|
|
2075
|
+
dllReference: Function
|
|
2076
|
+
loaderOptions: Function
|
|
2077
|
+
namedModules: Function
|
|
2078
|
+
namedChunks: Function
|
|
2079
|
+
hashedModuleIds: Function
|
|
2080
|
+
moduleFilenameH: Function
|
|
2081
|
+
aggressiveMerging: Function
|
|
2082
|
+
aggressiveSplitting: Function
|
|
2083
|
+
splitChunks: Function
|
|
2084
|
+
chunkModuleIdRange: Function
|
|
2085
|
+
dedupe: Function
|
|
2086
|
+
limitChunkCount: Function
|
|
2087
|
+
minChunkSize: Function
|
|
2088
|
+
occurrenceOrder: Function
|
|
2089
|
+
moduleConcatenation: Function
|
|
2090
|
+
minifyJs: Function
|
|
2091
|
+
minifyCss: Function
|
|
2092
|
+
extractText: Function
|
|
2093
|
+
moment: Function
|
|
2094
|
+
[key: string]: Function
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
export interface PrefetchPathnameArgs extends BrowserPluginArgs {
|
|
2098
|
+
pathname: string
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
export interface RouteUpdateArgs extends BrowserPluginArgs {
|
|
2102
|
+
location: Location
|
|
2103
|
+
prevLocation: Location | null
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
export interface ShouldUpdateScrollArgs extends BrowserPluginArgs {
|
|
2107
|
+
prevRouterProps?: {
|
|
2108
|
+
location: Location
|
|
2109
|
+
}
|
|
2110
|
+
pathname: string
|
|
2111
|
+
routerProps: {
|
|
2112
|
+
location: Location & NavigateOptions<any>
|
|
2113
|
+
}
|
|
2114
|
+
getSavedScrollPosition: Function
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
export interface WrapPageElementBrowserArgs<
|
|
2118
|
+
DataType = Record<string, unknown>,
|
|
2119
|
+
PageContextType = Record<string, unknown>,
|
|
2120
|
+
LocationState = WindowLocation["state"],
|
|
2121
|
+
> extends BrowserPluginArgs {
|
|
2122
|
+
element: React.ReactElement
|
|
2123
|
+
props: PageProps<DataType, PageContextType, LocationState>
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
export interface WrapRootElementBrowserArgs extends BrowserPluginArgs {
|
|
2127
|
+
element: React.ReactElement
|
|
2128
|
+
pathname: string
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
export interface BrowserPluginArgs {
|
|
2132
|
+
getResourceURLsForPathname: Function
|
|
2133
|
+
[key: string]: unknown
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
export interface RouteUpdateDelayedArgs extends BrowserPluginArgs {
|
|
2137
|
+
location: Location
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
export interface ServiceWorkerArgs extends BrowserPluginArgs {
|
|
2141
|
+
serviceWorker: ServiceWorkerRegistration
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
export interface RootErrorArgs extends BrowserPluginArgs {
|
|
2145
|
+
error: unknown
|
|
2146
|
+
/** React's error info: the component stack, and for `onCaughtError` the boundary that caught it */
|
|
2147
|
+
errorInfo: { componentStack?: string | null; errorBoundary?: React.Component<any, any> | null }
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
export interface NodeInput {
|
|
2151
|
+
id: string
|
|
2152
|
+
parent?: string | null
|
|
2153
|
+
children?: string[]
|
|
2154
|
+
internal: {
|
|
2155
|
+
type: string
|
|
2156
|
+
mediaType?: string
|
|
2157
|
+
content?: string
|
|
2158
|
+
contentDigest: string
|
|
2159
|
+
description?: string
|
|
2160
|
+
contentFilePath?: string
|
|
2161
|
+
}
|
|
2162
|
+
[key: string]: unknown
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
export interface Node extends NodeInput {
|
|
2166
|
+
parent: string | null
|
|
2167
|
+
children: string[]
|
|
2168
|
+
internal: NodeInput["internal"] & {
|
|
2169
|
+
owner: string
|
|
2170
|
+
}
|
|
2171
|
+
[key: string]: unknown
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
export interface Page<TContext = Record<string, unknown>> {
|
|
2175
|
+
path: string
|
|
2176
|
+
matchPath?: string
|
|
2177
|
+
component: string
|
|
2178
|
+
context?: TContext
|
|
2179
|
+
ownerNodeId?: string
|
|
2180
|
+
defer?: boolean
|
|
2181
|
+
/** Gatsby's slice alias map (ignored: goatly does not support Slices) */
|
|
2182
|
+
slices?: Record<string, string>
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export interface SliceInput<TContext = Record<string, unknown>> {
|
|
2186
|
+
id: string
|
|
2187
|
+
component: string
|
|
2188
|
+
context?: TContext
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
export interface IPluginRefObject {
|
|
2192
|
+
resolve: string
|
|
2193
|
+
options?: IPluginRefOptions
|
|
2194
|
+
parentDir?: string
|
|
2195
|
+
/** @private Internal key used by create-gatsby during plugin installation. Not necessary to define and can be removed. */
|
|
2196
|
+
__key?: string
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
export type PluginRef = string | IPluginRefObject
|
|
2200
|
+
|
|
2201
|
+
export interface IPluginRefOptions {
|
|
2202
|
+
plugins?: PluginRef[]
|
|
2203
|
+
path?: string
|
|
2204
|
+
[option: string]: unknown
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
export interface PluginOptionsSchemaArgs {
|
|
2208
|
+
Joi: PluginOptionsSchemaJoi
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
/**
|
|
2212
|
+
* Send body of response
|
|
2213
|
+
*/
|
|
2214
|
+
type Send<T> = (body: T) => void
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Gatsby Function route response
|
|
2218
|
+
*/
|
|
2219
|
+
export interface GatsbyFunctionResponse<T = any> extends ServerResponse {
|
|
2220
|
+
/**
|
|
2221
|
+
* Send `any` data in response
|
|
2222
|
+
*/
|
|
2223
|
+
send: Send<T>
|
|
2224
|
+
/**
|
|
2225
|
+
* Send `JSON` data in response
|
|
2226
|
+
*/
|
|
2227
|
+
json: Send<T>
|
|
2228
|
+
/**
|
|
2229
|
+
* Set the HTTP status code of the response
|
|
2230
|
+
*/
|
|
2231
|
+
status: (statusCode: number) => GatsbyFunctionResponse<T>
|
|
2232
|
+
redirect(url: string): GatsbyFunctionResponse<T>
|
|
2233
|
+
redirect(status: number, url: string): GatsbyFunctionResponse<T>
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
/**
|
|
2237
|
+
* Gatsby function route request
|
|
2238
|
+
*/
|
|
2239
|
+
export interface GatsbyFunctionRequest<ReqBody = any> extends IncomingMessage {
|
|
2240
|
+
/**
|
|
2241
|
+
* object of values from URL query parameters (after the ? in the URL)
|
|
2242
|
+
*/
|
|
2243
|
+
query: Record<string, string>
|
|
2244
|
+
|
|
2245
|
+
/**
|
|
2246
|
+
* object of values from route parameters
|
|
2247
|
+
*/
|
|
2248
|
+
params: Record<string, string>
|
|
2249
|
+
body: ReqBody
|
|
2250
|
+
/**
|
|
2251
|
+
* object of `cookies` from header
|
|
2252
|
+
*/
|
|
2253
|
+
cookies: Record<string, string>
|
|
2254
|
+
/**
|
|
2255
|
+
* Optional field to store the full raw URL by adapters
|
|
2256
|
+
*/
|
|
2257
|
+
rawUrl?: string
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
export interface GatsbyFunctionBodyParserCommonMiddlewareConfig {
|
|
2261
|
+
type?: string
|
|
2262
|
+
limit?: string | number
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
export interface GatsbyFunctionBodyParserUrlencodedConfig extends GatsbyFunctionBodyParserCommonMiddlewareConfig {
|
|
2266
|
+
extended: boolean
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
export interface GatsbyFunctionBodyParserConfig {
|
|
2270
|
+
json?: GatsbyFunctionBodyParserCommonMiddlewareConfig
|
|
2271
|
+
raw?: GatsbyFunctionBodyParserCommonMiddlewareConfig
|
|
2272
|
+
text?: GatsbyFunctionBodyParserCommonMiddlewareConfig
|
|
2273
|
+
urlencoded?: GatsbyFunctionBodyParserUrlencodedConfig
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
export interface GatsbyFunctionConfig {
|
|
2277
|
+
bodyParser?: GatsbyFunctionBodyParserConfig
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
declare namespace NodeJS {
|
|
2281
|
+
interface Global {
|
|
2282
|
+
__GATSBY: {
|
|
2283
|
+
buildId: string
|
|
2284
|
+
root: string
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
}
|