1 | ;
|
2 |
|
3 | /* eslint-disable no-unused-vars */
|
4 |
|
5 | /** */
|
6 | const GatsbyReporter = {
|
7 | /**
|
8 | * @callback GatsbyReporterFn
|
9 | * @param {string} message Message to display
|
10 | * @returns {void}
|
11 | */
|
12 |
|
13 | /**
|
14 | * @callback GatsbyReporterFnWithError
|
15 | * @param {string} message Message to display
|
16 | * @param {Error}[error] Optional error object
|
17 | * @returns {void}
|
18 | */
|
19 |
|
20 | /**
|
21 | * @type {GatsbyReporterFn}
|
22 | * @example
|
23 | * reporter.info(`text`)
|
24 | */
|
25 | info: true,
|
26 |
|
27 | /**
|
28 | * @type {GatsbyReporterFn}
|
29 | * @example
|
30 | * reporter.warn(`text`)
|
31 | */
|
32 | warn: true,
|
33 |
|
34 | /**
|
35 | * @type {GatsbyReporterFnWithError}
|
36 | * @example
|
37 | * reporter.error(`text`, new Error('something'))
|
38 | */
|
39 | error: true,
|
40 |
|
41 | /**
|
42 | * @type {GatsbyReporterFnWithError}
|
43 | * @example
|
44 | * reporter.panic(`text`, new Error('something'))
|
45 | */
|
46 | panic: true,
|
47 |
|
48 | /**
|
49 | * @type {GatsbyReporterFnWithError}
|
50 | * @example
|
51 | * reporter.panicOnBuild(`text`, new Error('something'))
|
52 | */
|
53 | panicOnBuild: true,
|
54 |
|
55 | /**
|
56 | * Note that this method only works if the --verbose option has
|
57 | * been passed to the CLI
|
58 | * @type {GatsbyReporterFn}
|
59 | * @example
|
60 | * reporter.verbose(`text`)
|
61 | */
|
62 | verbose: true
|
63 | };
|
64 | /** */
|
65 |
|
66 | const GatsbyCache = {
|
67 | /**
|
68 | * Retrieve cached value
|
69 | * @param {string} key Cache key
|
70 | * @returns {Promise<any>} Promise resolving to cached value
|
71 | * @example
|
72 | * const value = await cache.get(`unique-key`)
|
73 | */
|
74 | get: true,
|
75 |
|
76 | /**
|
77 | * Cache value
|
78 | * @param {string} key Cache key
|
79 | * @param {any} value Value to be cached
|
80 | * @returns {Promise<any>} Promise resolving to cached value
|
81 | * @example
|
82 | * await cache.set(`unique-key`, value)
|
83 | */
|
84 | set: true
|
85 | };
|
86 | /** */
|
87 |
|
88 | const GatsbyTracing = {
|
89 | /**
|
90 | * Global tracer instance. Check
|
91 | * [opentracing Tracer documentation](https://opentracing-javascript.surge.sh/classes/tracer.html)
|
92 | * for more details.
|
93 | * @type {Opentracing.Tracer}
|
94 | */
|
95 | tracer: true,
|
96 |
|
97 | /**
|
98 | * Tracer span representing API run. Check
|
99 | * [opentracing Span documentation](https://opentracing-javascript.surge.sh/classes/span.html)
|
100 | * for more details.
|
101 | * @type {Opentracing.Span}
|
102 | */
|
103 | parentSpan: true,
|
104 |
|
105 | /**
|
106 | * @callback GatsbyTracing.StartSpan
|
107 | * @param {string} spanName name of the span
|
108 | * @returns {Opentracing.Span}
|
109 | */
|
110 |
|
111 | /**
|
112 | * Start a tracing span. The span will be created as a child of the currently
|
113 | * running API span. This is a convenience wrapper for
|
114 | * ```js
|
115 | * tracing.tracer.startSpan(`span-name`, { childOf: tracing.parentSpan}).
|
116 | * ```
|
117 | * @type {GatsbyTracing.StartSpan}
|
118 | * @example
|
119 | * exports.sourceNodes = async ({ actions, tracing }) => {
|
120 | * const span = tracing.startSpan(`foo`)
|
121 | *
|
122 | * // Perform any span operations. E.g. add a tag to your span
|
123 | * span.setTag(`bar`, `baz`)
|
124 | *
|
125 | * // Rest of your plugin code
|
126 | *
|
127 | * span.finish()
|
128 | * }
|
129 | */
|
130 | startSpan: true
|
131 | };
|
132 | /** */
|
133 |
|
134 | const GatsbyNodeHelpers = {
|
135 | /**
|
136 | * Key-value store used to persist results of time/memory/cpu intensive
|
137 | * tasks. All functions are async and return promises.
|
138 | * @type {GatsbyCache}
|
139 | */
|
140 | cache: true,
|
141 |
|
142 | /**
|
143 | * Get cache instance by name - this should only be used by plugins that
|
144 | * accept subplugins.
|
145 | * @param {string} id Test
|
146 | * @returns {GatsbyCache} See [`cache`](#cache) section for reference.
|
147 | */
|
148 | getCache: true,
|
149 |
|
150 | /**
|
151 | * Create a stable content digest from a string or object, you can use the
|
152 | * result of this function to set the `internal.contentDigest` field
|
153 | * on nodes. Gatsby uses the value of this field to invalidate stale data
|
154 | * when your content changes.
|
155 | * @param {(string|object)} input
|
156 | * @returns {string} Hash string
|
157 | * @example
|
158 | * const node = {
|
159 | * ...nodeData,
|
160 | * internal: {
|
161 | * type: `TypeOfNode`,
|
162 | * contentDigest: createContentDigest(nodeData)
|
163 | * }
|
164 | * }
|
165 | */
|
166 | createContentDigest: true,
|
167 |
|
168 | /**
|
169 | * Collection of functions used to programmatically modify Gatsby’s internal state.
|
170 | *
|
171 | * See [`actions`](/docs/actions/) reference.
|
172 | * @type {Actions}
|
173 | * @deprecated Will be removed in gatsby 3.0. Use [actions](#actions)
|
174 | * instead.
|
175 | */
|
176 | boundActionCreators: true,
|
177 |
|
178 | /**
|
179 | * Collection of functions used to programmatically modify Gatsby’s internal state.
|
180 | *
|
181 | * See [`actions`](/docs/actions/) reference.
|
182 | * @type {Actions}
|
183 | */
|
184 | actions: true,
|
185 |
|
186 | /**
|
187 | * Get content for a node from the plugin that created it.
|
188 | * @param {Node} node
|
189 | * @returns {Promise<string>}
|
190 | * @example
|
191 | * module.exports = async function onCreateNode(
|
192 | * { node, loadNodeContent, actions, createNodeId }
|
193 | * ) {
|
194 | * if (node.internal.mediaType === 'text/markdown') {
|
195 | * const { createNode, createParentChildLink } = actions
|
196 | * const textContent = await loadNodeContent(node)
|
197 | * // process textContent and create child nodes
|
198 | * }
|
199 | * }
|
200 | */
|
201 | loadNodeContent: true,
|
202 |
|
203 | /**
|
204 | * Internal redux state used for application state. Do not use, unless you
|
205 | * absolutely must. Store is considered a private API and can change with
|
206 | * any version.
|
207 | * @type {Redux.Store}
|
208 | */
|
209 | store: true,
|
210 |
|
211 | /**
|
212 | * Internal event emitter / listener. Do not use, unless you absolutely
|
213 | * must. Emitter is considered a private API and can change with any version.
|
214 | * @type {Emitter}
|
215 | */
|
216 | emitter: true,
|
217 |
|
218 | /**
|
219 | * Get array of all nodes.
|
220 | * @returns {Node[]} Array of nodes.
|
221 | * @example
|
222 | * const allNodes = getNodes()
|
223 | */
|
224 | getNodes: true,
|
225 |
|
226 | /**
|
227 | * Get single node by given ID.
|
228 | * Don't use this in graphql resolvers - see
|
229 | * [`getNodeAndSavePathDependency`](#getNodeAndSavePathDependency).
|
230 | * @param {string} ID id of the node.
|
231 | * @returns {Node} Single node instance.
|
232 | * @example
|
233 | * const node = getNode(id)
|
234 | */
|
235 | getNode: true,
|
236 |
|
237 | /**
|
238 | * Get array of nodes of given type.
|
239 | * @param {string} Type of nodes
|
240 | * @returns {Node[]} Array of nodes.
|
241 | * @example
|
242 | * const markdownNodes = getNodesByType(`MarkdownRemark`)
|
243 | */
|
244 | getNodesByType: true,
|
245 |
|
246 | /**
|
247 | * Compares `contentDigest` of cached node with passed value
|
248 | * to determine if node has changed.
|
249 | *
|
250 | * @param {string} id of node
|
251 | * @param {string} contentDigest of node
|
252 | * @returns {boolean}
|
253 | * @deprecated This check is done internally in Gatsby and it's not necessary to use it in plugins. Will be removed in gatsby 3.0.
|
254 | */
|
255 | hasNodeChanged: true,
|
256 |
|
257 | /**
|
258 | * Set of utilities to output information to user
|
259 | * @type {GatsbyReporter}
|
260 | */
|
261 | reporter: true,
|
262 |
|
263 | /**
|
264 | * Get single node by given ID and create dependency for given path.
|
265 | * This should be used instead of `getNode` in graphql resolvers to enable
|
266 | * tracking dependencies for query results. If it's not used Gatsby will
|
267 | * not rerun query if node changes leading to stale query results. See
|
268 | * [Page -> Node Dependency Tracking](/docs/page-node-dependencies/)
|
269 | * for more details.
|
270 | * @param {string} ID id of the node.
|
271 | * @param {string} path of the node.
|
272 | * @returns {Node} Single node instance.
|
273 | */
|
274 | getNodeAndSavePathDependency: true,
|
275 |
|
276 | /**
|
277 | * Utility function useful to generate globally unique and stable node IDs.
|
278 | * It will generate different IDs for different plugins if they use same
|
279 | * input.
|
280 | *
|
281 | * @param {string} input
|
282 | * @returns {string} UUIDv5 ID string
|
283 | * @example
|
284 | * const node = {
|
285 | * id: createNodeId(`${backendData.type}${backendData.id}`),
|
286 | * ...restOfNodeData
|
287 | * }
|
288 | */
|
289 | createNodeId: true,
|
290 |
|
291 | /**
|
292 | * Set of utilities that allow adding more detailed tracing for plugins.
|
293 | * Check
|
294 | * [Performance tracing](https://www.gatsbyjs.org/docs/performance-tracing)
|
295 | * page for more details.
|
296 | * @type {GatsbyTracing}
|
297 | */
|
298 | tracing: true,
|
299 |
|
300 | /**
|
301 | * Use to prefix resources URLs. `pathPrefix` will be either empty string or
|
302 | * path that starts with slash and doesn't end with slash. Check
|
303 | * [Adding a Path Prefix](https://www.gatsbyjs.org/docs/path-prefix/)
|
304 | * page for details about path prefixing.
|
305 | * @type {string}
|
306 | */
|
307 | pathPrefix: true
|
308 | };
|
309 | module.exports = GatsbyNodeHelpers;
|
310 | //# sourceMappingURL=api-node-helpers-docs.js.map |
\ | No newline at end of file |