<commit_before>import "isomorphic-fetch"
import "regenerator-runtime/runtime"

import { isEmpty } from "lodash"
import { version as ReactionVersion } from "package.json"
import RelayClientSSR from "react-relay-network-modern-ssr/node8/client"
import RelayServerSSR from "react-relay-network-modern-ssr/node8/server"
import { Environment, RecordSource, RelayNetwork, Store } from "relay-runtime"
import { data as sd } from "sharify"

import {
  cacheMiddleware,
  errorMiddleware,
  loggerMiddleware,
  RelayNetworkLayer,
  urlMiddleware,
} from "react-relay-network-modern/node8"
import { metaphysicsErrorHandlerMiddleware } from "./middleware/metaphysicsErrorHandlerMiddleware"
import { metaphysicsExtensionsLoggerMiddleware } from "./middleware/metaphysicsExtensionsLoggerMiddleware"
import { principalFieldErrorHandlerMiddleware } from "./middleware/principalFieldErrorHandlerMiddleware"
import { searchBarImmediateResolveMiddleware } from "./middleware/searchBarImmediateResolveMiddleware"

const isServer = typeof window === "undefined"
const isDevelopment =
  (isServer ? process.env.NODE_ENV : sd.NODE_ENV) === "development"

// Only log on the client during development
const loggingEnabled = isDevelopment && !isServer

const METAPHYSICS_ENDPOINT = isServer
  ? process.env.METAPHYSICS_ENDPOINT
  : sd.METAPHYSICS_ENDPOINT

const USER_AGENT = `Reaction/${ReactionVersion}`

interface Config {
  cache?: object
  user?: User
  checkStatus?: boolean
  relayNetwork?: RelayNetwork
  userAgent?: string
}

export interface RelaySSREnvironment extends Environment {
  relaySSRMiddleware: RelayClientSSR | RelayServerSSR
  toggleFetching?: (isFetching) => void
}

export function createRelaySSREnvironment(config: Config = {}) {
  const { cache = {}, checkStatus, user, relayNetwork, userAgent } = config
<commit_msg>[relay] Point network layer at v2.<commit_after>import "isomorphic-fetch"
import "regenerator-runtime/runtime"

import { isEmpty } from "lodash"
import { version as ReactionVersion } from "package.json"
import RelayClientSSR from "react-relay-network-modern-ssr/node8/client"
import RelayServerSSR from "react-relay-network-modern-ssr/node8/server"
import { Environment, RecordSource, RelayNetwork, Store } from "relay-runtime"
import { data as sd } from "sharify"

import {
  cacheMiddleware,
  errorMiddleware,
  loggerMiddleware,
  RelayNetworkLayer,
  urlMiddleware,
} from "react-relay-network-modern/node8"
import { metaphysicsErrorHandlerMiddleware } from "./middleware/metaphysicsErrorHandlerMiddleware"
import { metaphysicsExtensionsLoggerMiddleware } from "./middleware/metaphysicsExtensionsLoggerMiddleware"
import { principalFieldErrorHandlerMiddleware } from "./middleware/principalFieldErrorHandlerMiddleware"
import { searchBarImmediateResolveMiddleware } from "./middleware/searchBarImmediateResolveMiddleware"

const isServer = typeof window === "undefined"
const isDevelopment =
  (isServer ? process.env.NODE_ENV : sd.NODE_ENV) === "development"

// Only log on the client during development
const loggingEnabled = isDevelopment && !isServer

const METAPHYSICS_ENDPOINT = `${
  isServer ? process.env.METAPHYSICS_ENDPOINT : sd.METAPHYSICS_ENDPOINT
}/v2`

const USER_AGENT = `Reaction/${ReactionVersion}`

interface Config {
  cache?: object
  user?: User
  checkStatus?: boolean
  relayNetwork?: RelayNetwork
  userAgent?: string
}

export interface RelaySSREnvironment extends Environment {
  relaySSRMiddleware: RelayClientSSR | RelayServerSSR
  toggleFetching?: (isFetching) => void
}

export function createRelaySSREnvironment(config: Config = {}) {
  const { cache = {}, checkStatus, user, relayNetwork, userAgent } = config

{'fraction_non_alphanumeric': 0.09239574816026165, 'fraction_numerical': 0.0021804306350504225, 'mean_word_length': 6.196078431372549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3823343', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1075, 'n_words': 252}