-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby): Migrate src/redux/plugin-runner to TypeScript (#22476)
* chore(gatsby): Migrate src/redux/plugin-runner to TypeScript * Improve typing and reduce module side effects * Add return type Co-authored-by: Blaine Kasten <[email protected]>
- Loading branch information
1 parent
babc491
commit d8b667a
Showing
3 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Span } from "opentracing" | ||
import { emitter } from "./index" | ||
import apiRunnerNode from "../utils/api-runner-node" | ||
import { ActivityTracker } from "../../" | ||
|
||
type Plugin = any // TODO | ||
|
||
// This might make sense to live somewhere else | ||
interface ICreatePageAction { | ||
graphql<TData, TVariables = any>( | ||
query: string, | ||
variables?: TVariables | ||
): Promise<{ | ||
errors?: any | ||
data?: TData | ||
}> | ||
traceId: "initial-createPages" | ||
waitForCascadingActions: boolean | ||
parentSpan: Span | ||
activity: ActivityTracker | ||
type: `CREATE_PAGE` | ||
contextModified: boolean | ||
plugin: Plugin | ||
payload: { | ||
internalComponentName: string | ||
path: string | ||
matchPath: string | undefined | ||
component: string | ||
componentChunkName: string | ||
isCreatedByStatefulCreatePages: boolean | ||
context: { | ||
slug: string | ||
id: string | ||
} | ||
updatedAt: number | ||
pluginCreator__NODE: string | ||
pluginCreatorId: string | ||
componentPath: string | ||
} | ||
} | ||
|
||
export const startPluginRunner = (): void => { | ||
emitter.on(`CREATE_PAGE`, (action: ICreatePageAction) => { | ||
const page = action.payload | ||
apiRunnerNode( | ||
`onCreatePage`, | ||
{ page, traceId: action.traceId, parentSpan: action.parentSpan }, | ||
{ pluginSource: action.plugin.name, activity: action.activity } | ||
) | ||
}) | ||
} |