Skip to content

Commit

Permalink
ref(ts): Marginally improve types in sourceNodes apis (#7328)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser authored Jul 6, 2023
1 parent bca3249 commit 29cb5cd
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/gatsby/sourceNodes/appRegistryNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {SourceNodesArgs} from 'gatsby';

import getAppRegistry from '../utils/appRegistry';

export const sourceAppRegistryNodes = async ({actions, createContentDigest}) => {
export const sourceAppRegistryNodes = async ({
actions,
createContentDigest,
}: SourceNodesArgs) => {
const {createNode} = actions;

const appRegistry = await getAppRegistry();
Expand Down
4 changes: 3 additions & 1 deletion src/gatsby/sourceNodes/awsLambdLayerRegistryNodes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {SourceNodesArgs} from 'gatsby';

import awsLambdaRegistry from '../utils/awsLambdaLayerRegistry';

export const sourceAwsLambdaLayerRegistryNodes = async ({
actions,
createContentDigest,
}) => {
}: SourceNodesArgs) => {
const {createNode} = actions;

const layerMap = await awsLambdaRegistry.getLayerMap();
Expand Down
8 changes: 5 additions & 3 deletions src/gatsby/sourceNodes/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {GatsbyNode} from 'gatsby';

import {sourceAppRegistryNodes} from './appRegistryNodes';
import {sourceAwsLambdaLayerRegistryNodes} from './awsLambdLayerRegistryNodes';
import {sourcePackageRegistryNodes} from './packageRegistryNodes';
import {sourcePlatformNodes} from './platformNodes';
import {relayMetricsNodes} from './relayMetricsNodes';
import {piiFieldsNodes} from './relayPiiNodes';

async function main(params) {
const sourceNodes: GatsbyNode['sourceNodes'] = async params => {
relayMetricsNodes(params);
piiFieldsNodes(params);
await sourcePlatformNodes(params);
await sourcePackageRegistryNodes(params);
await sourceAppRegistryNodes(params);
await sourceAwsLambdaLayerRegistryNodes(params);
}
};

export default main;
export default sourceNodes;
7 changes: 6 additions & 1 deletion src/gatsby/sourceNodes/packageRegistryNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {SourceNodesArgs} from 'gatsby';

import getPackageRegistry from '../utils/packageRegistry';

export const sourcePackageRegistryNodes = async ({actions, createContentDigest}) => {
export const sourcePackageRegistryNodes = async ({
actions,
createContentDigest,
}: SourceNodesArgs) => {
const {createNode} = actions;

const packageRegistry = await getPackageRegistry();
Expand Down
4 changes: 3 additions & 1 deletion src/gatsby/sourceNodes/platformNodes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {SourceNodesArgs} from 'gatsby';

import PlatformRegistry from '../../shared/platformRegistry';

export const sourcePlatformNodes = async ({
actions,
reporter,
createNodeId,
createContentDigest,
}) => {
}: SourceNodesArgs) => {
const {createNode} = actions;

const platformRegistry = new PlatformRegistry();
Expand Down
14 changes: 11 additions & 3 deletions src/gatsby/sourceNodes/relayMetricsNodes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import {Node, SourceNodesArgs} from 'gatsby';

import metrics from '../../data/relay_metrics.json';

export const relayMetricsNodes = ({actions, createNodeId, createContentDigest}) => {
export const relayMetricsNodes = ({
actions,
createNodeId,
createContentDigest,
}: SourceNodesArgs) => {
const {createNode, createParentChildLink} = actions;

metrics.forEach(metric => {
const metricNode = {
const metricNode: Node = {
...metric,
id: createNodeId(metric.name),
// @ts-expect-error TODO(epurkhiser): Understand what additional properties we need to add
internal: {
type: 'RelayMetric',
contentDigest: createContentDigest(metric),
Expand All @@ -15,9 +22,10 @@ export const relayMetricsNodes = ({actions, createNodeId, createContentDigest})

createNode(metricNode);

const descriptionNode = {
const descriptionNode: Node = {
id: createNodeId(metric.name + '_description'),
parent: metricNode.id,
// @ts-expect-error TODO(epurkhiser): Understand what additional properties we need to add
internal: {
content: metric.description,
contentDigest: createContentDigest(metric.description),
Expand Down
15 changes: 13 additions & 2 deletions src/gatsby/sourceNodes/relayPiiNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
import fs from 'fs';
import path from 'path';

export const piiFieldsNodes = ({actions, createNodeId, createContentDigest}) => {
import {SourceNodesArgs} from 'gatsby';

interface PiiField {
additional_properties: string;
path: string;
}

export const piiFieldsNodes = ({
actions,
createNodeId,
createContentDigest,
}: SourceNodesArgs) => {
const {createNode} = actions;

const data = fs.readFileSync(
path.join(__dirname, '..', '..', 'data', 'relay_event_pii.json'),
'utf-8'
);
const fields = JSON.parse(data);
const fields: PiiField[] = JSON.parse(data);

fields.forEach((field, index) => {
const fieldNode = {
Expand Down

1 comment on commit 29cb5cd

@vercel
Copy link

@vercel vercel bot commented on 29cb5cd Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev
docs.sentry.io

Please sign in to comment.