repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
tony-aq/optic
workspaces/ui-v2/src/hooks/util/useRunOnKeypress.ts
<reponame>tony-aq/optic import { KeyboardEvent, useCallback } from 'react'; export const useRunOnKeypress = <T extends (...args: any) => any>( fn: T, options: { keys?: Set<string>; inputTagNames?: Set<string>; } = {} ) => { return useCallback( (e: KeyboardEvent) => { const { keys, inputTagNam...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/ReviewEndpointDiffPage/ReviewEndpointDiffPageContainer.tsx
import React, { FC } from 'react'; import { RouteComponentProps } from 'react-router'; import { LinearProgress } from '@material-ui/core'; import { useEndpointDiffs } from '<src>/pages/diffs/hooks/useEndpointDiffs'; import { useNewBodyDiffInterpretations, useShapeDiffInterpretations, } from '<src>/pages/diffs/hooks...
tony-aq/optic
workspaces/optic-domain/src/shapes.ts
// Shape events export enum ICoreShapeKinds { ObjectKind = '$object', ListKind = '$list', MapKind = '$map', OneOfKind = '$oneOf', AnyKind = '$any', StringKind = '$string', NumberKind = '$number', BooleanKind = '$boolean', NullableKind = '$nullable', OptionalKind = '$optional', UnknownKind = '$unkn...
tony-aq/optic
workspaces/ui-v2/src/store/documentationEdit/thunks.ts
<filename>workspaces/ui-v2/src/store/documentationEdit/thunks.ts import { createAsyncThunk } from '@reduxjs/toolkit'; import { v4 as uuidv4 } from 'uuid'; import * as Sentry from '@sentry/react'; import { IForkableSpectacle } from '@useoptic/spectacle'; import { AddContribution, CQRSCommand, JsonType, PrunePat...
tony-aq/optic
workspaces/ui-v2/src/pages/changelogHistory/components/ConfirmResetModal.tsx
import React, { FC, useState } from 'react'; import { Dialog, DialogActions, DialogContent, DialogTitle, makeStyles, } from '@material-ui/core'; import * as Sentry from '@sentry/react'; import { Button } from '<src>/components'; import { useSpectacleContext } from '<src>/contexts/spectacle-provider'; import ...
tony-aq/optic
workspaces/cli-server/src/standalone-server.ts
import { CliServer } from './server'; import { Client } from '@useoptic/cli-client'; async function main(inputs: { opticProjectDirectory: string }) { const apiServer = new CliServer({ cloudApiBaseUrl: 'fixme', }); const serverState = await apiServer.start(); const baseUrl = `http://localhost:${serverState....
tony-aq/optic
workspaces/ui-v2/src/components/Panel.tsx
import React, { FC, Ref } from 'react'; import classNames from 'classnames'; import { makeStyles } from '@material-ui/core'; import { FontFamilyMono } from '<src>/styles'; type PanelProps = { header: React.ReactNode; contentRef?: Ref<HTMLDivElement>; }; export const Panel: FC< PanelProps & React.HtmlHTMLAttribu...
tony-aq/optic
workspaces/ui-v2/src/store/index.ts
export * from './root'; export { actions as diffActions } from './diff'; export { actions as pathsActions } from './paths'; export { actions as endpointActions } from './endpoints'; export { actions as documentationEditActions } from './documentationEdit'; export { actions as shapeActions } from './shapes'; export { ac...
tony-aq/optic
workspaces/ui-v2/src/components/DataFetchers.tsx
<filename>workspaces/ui-v2/src/components/DataFetchers.tsx import React, { FC, useEffect } from 'react'; import { shapeActions, selectors, useAppSelector, useAppDispatch, } from '<src>/store'; import { useSpectacleContext } from '<src>/contexts/spectacle-provider'; import { IFieldDetails, IShapeRenderer } from ...
tony-aq/optic
workspaces/cli-shared/src/conversation.ts
import colors from 'colors'; import { promise as OraPromise, Options as OraOptions } from 'ora'; export function fromOptic(msg: string) { return msg .split('\n') .map((line) => `${colors.cyan('[optic]')} ${line}`) .join('\n'); } export function fromOpticVerbose(msg: string) { return msg .split('\n...
tony-aq/optic
workspaces/shape-hash/src/index.ts
import { jsonToShapeHash, toBytes, toJsonExample } from './json-to-shape-hash'; export { jsonToShapeHash, toBytes, toJsonExample };
tony-aq/optic
workspaces/optic-domain/tests/engine.ts
import Tap from 'tap'; import * as OpticEngine from '@useoptic/optic-engine-wasm/build'; Tap.test('OpticEngine spec_from_events', async (test) => { let spec = OpticEngine.spec_from_events('[]'); test.ok(spec); });
tony-aq/optic
workspaces/ui-v2/src/types/index.ts
<reponame>tony-aq/optic export * from './async'; export * from './changes'; export * from './contributions'; export * from './endpoints'; export * from './shapes';
tony-aq/optic
workspaces/ui-v2/src/components/ContributionsList/ContributionList.tsx
<gh_stars>100-1000 import React, { FC } from 'react'; import { IFieldDetails } from '<src>/types'; type ContributionsListProps = { fieldDetails: IFieldDetails[]; renderField: (contribution: IFieldDetails) => React.ReactElement; }; export const ContributionsList: FC<ContributionsListProps> = ({ fieldDetails, ...
tony-aq/optic
workspaces/ui-v2/src/store/endpoints/thunks.ts
import { createAsyncThunk } from '@reduxjs/toolkit'; import * as Sentry from '@sentry/react'; import { IForkableSpectacle } from '@useoptic/spectacle'; import { ChangeType, IEndpoint } from '<src>/types'; import { getEndpointId } from '<src>/utils'; import groupBy from 'lodash.groupby'; import { convertSpectacleChan...
tony-aq/optic
workspaces/spectacle/src/index.ts
<gh_stars>100-1000 export * from './openapi'; export * from './spectacle'; export * from './types';
tony-aq/optic
workspaces/ui-v2/src/pages/onboarding/WelcomePage.tsx
import * as React from 'react'; import { makeStyles } from '@material-ui/core/styles'; const useStyles = makeStyles((theme) => ({ body: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100vh', }, })); export default function WelcomePage() { const classes = useStyles();...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/AddEndpointsPage/hooks/index.ts
export * from './useCheckboxState';
tony-aq/optic
workspaces/cli-server/src/routers/spec-router.ts
import { getPathsRelativeToCwd, IOpticTaskRunnerConfig, parseRule, readApiConfig, } from '@useoptic/cli-config'; import express from 'express'; import bodyParser from 'body-parser'; import path from 'path'; import fs from 'fs-extra'; import Bottleneck from 'bottleneck'; import sortBy from 'lodash.sortby'; impo...
tony-aq/optic
workspaces/ui-v2/src/contexts/analytics/index.ts
export * from './AnalyticsStore';
tony-aq/optic
workspaces/ui-v2/src/pages/docs/components/DocPageNavigation.tsx
<reponame>tony-aq/optic import React, { FC } from 'react'; import { PromptNavigateAway } from '<src>/components'; import { ChangesSinceDropdown } from '<src>/pages/changelog/components/ChangelogDropdown'; import { useAppConfig } from '<src>/contexts/config/AppConfiguration'; import { useAppSelector, selectors } from '<...
tony-aq/optic
workspaces/api-checks/test/functional.ts
<reponame>tony-aq/optic import * as fs from 'fs'; import Tap from 'tap'; import { EndpointChangeChecks, Spectacle, checks, reports } from '../src/'; Tap.test('Successful check', async (test) => { const endpointChanges = await initEndpointChanges(); // The ./specification.json has a 404 in the only GET endpoint /...
tony-aq/optic
workspaces/ui-v2/src/store/spectacleUtils.ts
<gh_stars>100-1000 import { ChangeType } from '<src>/types'; export type SpectacleChange = { added?: boolean; changed?: boolean; removed?: boolean; }; export const convertSpectacleChangeToChangeType = ( spectacleChange: SpectacleChange ): ChangeType | null => spectacleChange.added ? 'added' : spectac...
tony-aq/optic
workspaces/cli-server/src/index.ts
import { Client } from '@useoptic/cli-client'; import lockfile from 'proper-lockfile'; import { CliDaemon } from './daemon'; import { fork } from 'child_process'; import fs from 'fs-extra'; import path from 'path'; import findProcess from 'find-process'; import * as uuid from 'uuid'; import { delay, developerDebugL...
tony-aq/optic
workspaces/ui-v2/src/pages/docs/components/DeleteEndpointConfirmationModal.tsx
import React, { FC } from 'react'; import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, makeStyles, } from '@material-ui/core'; import { EndpointName } from '<src>/components'; import { IEndpoint } from '<src>/types'; type DeleteEndpointConfirmationModalProps = { endp...
tony-aq/optic
workspaces/ui-v2/src/store/root.ts
import { configureStore } from '@reduxjs/toolkit'; import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'; import { reducer as diffReducer } from './diff'; import { reducer as documentationEditReducer } from './documentationEdit'; import { reducer as endpointsReducer } from './endpoints'; import ...
tony-aq/optic
workspaces/ui-v2/src/store/shapes/index.ts
<filename>workspaces/ui-v2/src/store/shapes/index.ts<gh_stars>100-1000 export * from './slice'; export * from './thunks';
tony-aq/optic
workspaces/ui-v2/src/pages/docs/components/MarkdownBodyContribution.tsx
import * as React from 'react'; import { ChangeEvent } from 'react'; import makeStyles from '@material-ui/styles/makeStyles'; import { TextField } from '@material-ui/core'; import classNames from 'classnames'; import { OpticBlueReadable } from '<src>/styles'; import ReactMarkdown from 'react-markdown'; import { useA...
tony-aq/optic
workspaces/cli-server/src/tasks/on-demand-initial-body-rust.ts
<gh_stars>100-1000 import { InitialBodiesWorkerRust, InitialBodiesWorkerConfig, LearnedBodies, } from '@useoptic/cli-shared/build/diffs/initial-bodies-worker-rust'; export { LearnedBodies }; export class OnDemandInitialBodyRust { private worker: InitialBodiesWorkerRust; constructor(config: InitialBodiesWork...
tony-aq/optic
workspaces/ui-v2/src/store/selectors/__tests__/documentationEditSelectors.test.ts
import { RootState } from '<src>/store/root'; import { getValidContributions, getDocumentationEditStagedCount, isEndpointRemoved, isEndpointEditable, isFieldRemoved, isFieldRemovedRoot, isEndpointFieldEditable, } from '../documentationEditSelectors'; import { getMockReduxStore } from './testHelpers'; le...
tony-aq/optic
workspaces/ui-v2/src/lib/parse-diff.ts
import jsonStringify from 'json-stable-stringify'; //@ts-ignore import sha1 from 'node-sha1'; import { IJsonTrail, normalize, } from '@useoptic/cli-shared/build/diffs/json-trail'; import { IDiff, IDiffWithShapeDiff, IShapeDiffResult, } from '@useoptic/cli-shared/build/diffs/diffs'; import { IInteractionTrail...
tony-aq/optic
workspaces/ui-v2/src/lib/shape-trail-parser.ts
import { IListItemTrail, IListTrail, INullableTrail, IObjectFieldTrail, IObjectTrail, IOneOfItemTrail, IOptionalTrail, IOptionalItemTrail, IShapeTrail, IShapeTrailComponent, } from '@useoptic/cli-shared/build/diffs/shape-trail'; import { ICoreShapeKinds, JsonType } from '@useoptic/optic-domain'; imp...
tony-aq/optic
workspaces/ui-v2/src/components/ContributionsList/index.ts
<reponame>tony-aq/optic<filename>workspaces/ui-v2/src/components/ContributionsList/index.ts export * from './ContributionList';
tony-aq/optic
workspaces/cli-shared/src/diffs/trail-parsers.ts
<reponame>tony-aq/optic<filename>workspaces/cli-shared/src/diffs/trail-parsers.ts import { IRequestSpecTrail } from './request-spec-trail'; import { IInteractionTrail } from './interaction-trail'; type EndpointForTrails = { pathId: string; method: string; query: { queryParametersId: string; } | null; req...
tony-aq/optic
workspaces/ui-v2/src/components/sharing/ShareButton.tsx
<filename>workspaces/ui-v2/src/components/sharing/ShareButton.tsx<gh_stars>100-1000 import React, { useCallback, useState } from 'react'; import { Button, Dialog, DialogContent, DialogActions, makeStyles, Typography, } from '@material-ui/core'; import ShareIcon from '@material-ui/icons/Share'; import { Shar...
tony-aq/optic
workspaces/ui-v2/src/components/layouts/FullWidth.tsx
<filename>workspaces/ui-v2/src/components/layouts/FullWidth.tsx import * as React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Container } from '@material-ui/core'; export function FullWidth(props: any) { const classes = useStyles(); return ( <Container maxWidth="lg" className...
tony-aq/optic
workspaces/cli-shared/test/tests/diff-worker-rust.ts
// Getting the Typescript compiler to find these in cli-shared/typings through // passing it a tsconfig has been successful :( /// <reference types="../../typings/stream-chain/index" /> /// <reference types="../../typings/stream-json/index" /> import Tap from 'tap'; import { FileSystemAvroCaptureSaver as CaptureSaver ...
tony-aq/optic
workspaces/ui-v2/src/components/loaders/Errors.tsx
import React from 'react'; import { CenteredColumn } from '../layouts/CenteredColumn'; import { makeStyles } from '@material-ui/styles'; import { Box, Typography } from '@material-ui/core'; import { ErrorOutline as ErrorOutlineIcon } from '@material-ui/icons'; export function FullPageError({ errorMessage }: { errorMes...
tony-aq/optic
workspaces/spectacle/test/utils.ts
import * as fs from 'fs'; export function loadEvents(file: string) { return JSON.parse(fs.readFileSync(file).toString('utf-8')); }
tony-aq/optic
workspaces/cli-config/src/human-readable-ids.d.ts
declare module 'human-readable-ids' { type ExportedRandom = { random: () => string; }; export const hri = ExportedRandom; export const humanReadableIds = ExportedRandom; }
tony-aq/optic
workspaces/ui-v2/src/types/endpoints.ts
<filename>workspaces/ui-v2/src/types/endpoints.ts import { ChangeType } from './changes'; export interface IPathParameter { id: string; name: string; isParameterized: boolean; description: string; endpointId: string; } export interface IPath { absolutePathPattern: string; parentPathId: string | null; ...
tony-aq/optic
workspaces/ui-v2/src/utils/findLongestCommonPath.ts
export function findLongestCommonPath(paths: string[][]): string { if (paths.length === 0) return '/'; let match: string[] = []; // sorted paths by lengths ascending const sortedPaths = paths .concat() .sort((a, b) => (a.length - b.length > 0 ? 1 : -1)); const shortestPath = sortedPaths[0]; const ot...
tony-aq/optic
workspaces/analytics/tests/EventBus.test.ts
import { newAnalyticsEventBus } from '../src/eventbus'; import { CliClientContext } from '../src/interfaces/TrackingEventBase'; import { UserLoggedInFromCLI } from '../src/cliEvents'; const getContext: (batchId: string) => Promise<CliClientContext> = async () => { return { clientId: 'testing', platform: 'furb...
tony-aq/optic
workspaces/ui-v2/src/pages/changelog/components/ValidateBatchId.tsx
<filename>workspaces/ui-v2/src/pages/changelog/components/ValidateBatchId.tsx import React, { FC } from 'react'; import { Redirect } from 'react-router-dom'; import { useBatchCommits } from '<src>/hooks/useBatchCommits'; import { useDocumentationPageLink } from '<src>/components/navigation/Routes'; export const Valida...
tony-aq/optic
workspaces/ui-v2/src/pages/changelogHistory/index.ts
export * from './ChangelogHistory';
tony-aq/optic
workspaces/ui-v2/src/utils/index.ts
<reponame>tony-aq/optic export * from './dateFormat'; export * from './endpoint-utilities'; export * from './go-to-anchor'; export * from './findLongestCommonPath'; export * from './pathMatcher';
tony-aq/optic
workspaces/ui-v2/src/store/shapes/types.ts
import { JsonType } from '@useoptic/optic-domain'; import { ChangeType } from '<src>/types'; export type ShapeId = string; export type ReduxField = { fieldId: string; name: string; shapeId: string; changes: ChangeType | null; contributions: Record<string, string>; }; export type ReduxShape = | { sh...
tony-aq/optic
workspaces/snapshot-tests/src/tasks/RfcStateAndInteractionsToDiffs/index.ts
import { ITaskExecutor, ITaskExecutorDependencies, ITaskExecutorOutput, ITaskSpecification, ITaskSpecificationInputs, TaskType, } from '../'; import { InteractionsFileToJsTaskOutput, InteractionsFileToJsTaskSpecification, } from '../InteractionsFileToJs'; import { EventsFileToJsTaskOutput, EventsFil...
tony-aq/optic
workspaces/cli-shared/src/diffs/initial-types.ts
import { IJsonTrail } from './json-trail'; import { LearningResults } from '@useoptic/optic-domain'; export type ILearnedBodies = LearningResults.UndocumentedEndpointBodies.LearnedBodies; export type ILearnedBody = LearningResults.UndocumentedEndpointBodies.LearnedBody; export type ILearnedQueryParameters = LearningRe...
tony-aq/optic
workspaces/ui-v2/src/store/selectors/shapeSelectors.ts
<reponame>tony-aq/optic import { SerializedError } from '@reduxjs/toolkit'; import * as Sentry from '@sentry/react'; import sortBy from 'lodash.sortby'; import { JsonType } from '@useoptic/optic-domain'; import { AsyncStatus, IShapeRenderer, IFieldDetails, QueryParameters, } from '<src>/types'; import { RootSt...
tony-aq/optic
workspaces/api-checks/src/spectacle.ts
import fs from 'fs'; import { InMemoryOpticContextBuilder } from '@useoptic/spectacle/build/in-memory'; import OpticEngine from '@useoptic/optic-engine-wasm'; import { makeSpectacle } from '@useoptic/spectacle'; export class Spectacle { constructor(public spectacle: any) {} static async fromFile(filename: string)...
tony-aq/optic
workspaces/cli-shared/src/command-session.ts
import { ChildProcess, spawn, SpawnOptions } from 'child_process'; import { EventEmitter } from 'events'; import treeKill from 'tree-kill'; import { developerDebugLogger } from './index'; export interface ICommandSessionConfig { command: string; environmentVariables: NodeJS.ProcessEnv; } class CommandSession { ...
tony-aq/optic
workspaces/local-cli/src/commands/init.ts
import { Command, flags } from '@oclif/command'; import { createFileTree, getPathsRelativeToConfig } from '@useoptic/cli-config'; import colors from 'colors'; import cli from 'cli-ux'; import fs from 'fs-extra'; import path from 'path'; import { developerDebugLogger, fromOptic } from '@useoptic/cli-shared'; import { tr...
tony-aq/optic
workspaces/cli-server/src/tasks/on-demand-trail-values-rust.ts
<reponame>tony-aq/optic import { ShapeDiffAffordancesWorker, ShapeDiffAffordancesConfig, ShapeDiffAffordances, } from '@useoptic/cli-shared/build/diffs/trail-values-worker-rust'; export { ShapeDiffAffordances }; export class OnDemandShapeDiffAffordancesRust { private worker: ShapeDiffAffordancesWorker; con...
tony-aq/optic
workspaces/optic-domain/src/index.ts
export * as AsyncTools from './async-tools'; export * as Streams from './streams'; export * as Commands from './commands'; export * as Shapes from './shapes'; export * as Interactions from './interactions'; export * from './commands'; export * from './shapes'; export * from './interactions'; export * from './streams';...
tony-aq/optic
workspaces/ui-v2/src/components/ShapeRenderer/OneOfTabs.tsx
import * as React from 'react'; import makeStyles from '@material-ui/styles/makeStyles'; import { useSharedStyles } from './SharedStyles'; import classNames from 'classnames'; import { useShapeRenderContext } from './ShapeRenderContext'; export type OneOfTabsProps = { choices: { label: string; id: string }[]; shap...
tony-aq/optic
workspaces/ui-v2/src/store/metadata.ts
<gh_stars>100-1000 import { createAsyncThunk, createSlice, SerializedError, } from '@reduxjs/toolkit'; import { v4 as uuidv4 } from 'uuid'; import * as Sentry from '@sentry/react'; import { Client } from '@useoptic/cli-client'; import { IOpticConfigRepository, IForkableSpectacle, } from '@useoptic/spectacle'...
tony-aq/optic
workspaces/ui-v2/src/pages/changelog/components/ChangelogAccessoryNavigation.tsx
<reponame>tony-aq/optic import React from 'react'; import { ChangesSinceDropdown } from '<src>/pages/changelog/components/ChangelogDropdown'; export function ChangelogPageAccessoryNavigation() { return ( <div style={{ paddingRight: 10, display: 'flex', flexDirection: 'row' }}> <ChangesSinceDropdown /> ...
tony-aq/optic
workspaces/ui-v2/src/pages/changelogHistory/components/index.ts
<filename>workspaces/ui-v2/src/pages/changelogHistory/components/index.ts export * from './ConfirmResetModal';
tony-aq/optic
workspaces/ui-v2/src/components/HighlightController.tsx
import React, { FC, useState } from 'react'; type HighlightControllerProps = { children: ( selectedItem: string | null, setSelectedItem: (selectedItem: string | null) => void ) => React.ReactElement; }; export const HighlightController: FC<HighlightControllerProps> = ({ children, }) => { const [select...
tony-aq/optic
workspaces/ui-v2/src/hooks/util/useDebouncedFn.ts
import { useMemo } from 'react'; import debounce from 'lodash.debounce'; export const useDebouncedFn = <T extends (...args: any) => any>( fn: T, ms: number ) => { return useMemo(() => debounce(fn, ms), [fn, ms]); };
tony-aq/optic
workspaces/api-checks/src/runner.ts
import path from 'path'; import { Spectacle } from './spectacle'; import { CheckFunction, EndpointChangeChecksOptions, CheckFunctionRegistry, } from './types'; export class EndpointChangeChecks { public sinceBatchCommitId: string; public spectacle: any; public checks: CheckFunctionRegistry = { added: [...
tony-aq/optic
workspaces/local-cli/src/commands/ingest/s3.ts
<reponame>tony-aq/optic<filename>workspaces/local-cli/src/commands/ingest/s3.ts<gh_stars>100-1000 import { Command, flags } from '@oclif/command'; import { ensureDaemonStarted } from '@useoptic/cli-server'; import { ingestS3 } from '@useoptic/cli-shared/build/captures/avro/file-system/ingest-s3-capture-saver'; import {...
tony-aq/optic
workspaces/ui-v2/src/components/ShapeRenderer/index.ts
export * from './ShapeRenderer';
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/ReviewEndpointDiffPage/index.ts
export * from './ReviewEndpointDiffPageContainer';
tony-aq/optic
workspaces/graph-lib/src/endpoints-graph/index.ts
import { GraphCommandHandler, mapAppend, NodeListWrapper } from '../shared'; export type NodeId = string; export enum NodeType { Path = 'Path', Request = 'Request', QueryParameters = 'QueryParameters', Response = 'Response', Endpoint = 'Endpoint', Body = 'Body', BatchCommit = 'BatchCommit', } export ty...
tony-aq/optic
workspaces/ui-v2/src/store/paths/index.ts
<reponame>tony-aq/optic<gh_stars>100-1000 export * from './slice';
tony-aq/optic
workspaces/spectacle-shared/src/index.ts
export * from './local-cli/client';
tony-aq/optic
workspaces/cli-shared/src/ingest/ingest-traffic-service.ts
<filename>workspaces/cli-shared/src/ingest/ingest-traffic-service.ts import { developerDebugLogger, ICaptureSaver } from '../index'; import express from 'express'; import bodyParser from 'body-parser'; import fs from 'fs-extra'; import path from 'path'; import getPort from 'get-port'; import http from 'http'; import { ...
tony-aq/optic
workspaces/analytics/src/uiEvents.ts
<reponame>tony-aq/optic<gh_stars>100-1000 import { TrackingEventBase } from './interfaces/TrackingEventBase'; type AnalyticsDispatcher = (event: TrackingEventBase<any>) => void; export class OpticUIEvents { constructor(private dispatch: AnalyticsDispatcher) {} // in-use // documentation page documentationPag...
tony-aq/optic
workspaces/ui-v2/src/components/ShapeRenderer/ShapeRowBase.tsx
<reponame>tony-aq/optic import * as React from 'react'; import { useCallback } from 'react'; import { makeStyles } from '@material-ui/core'; import { JsonType } from '@useoptic/optic-domain'; import { IndentSpaces, useSharedStyles } from './SharedStyles'; import { IFieldRenderer, IShapeRenderer } from '<src>/types'; i...
tony-aq/optic
workspaces/ui-v2/src/hooks/useInteraction.tsx
<reponame>tony-aq/optic<filename>workspaces/ui-v2/src/hooks/useInteraction.tsx<gh_stars>100-1000 import { useContext, useEffect, useState } from 'react'; import * as Sentry from '@sentry/react'; import { IHttpInteraction } from '@useoptic/optic-domain'; import { AsyncStatus } from '<src>/types'; import { CapturesServic...
tony-aq/optic
workspaces/cli-shared/src/captures/avro/index.ts
<filename>workspaces/cli-shared/src/captures/avro/index.ts import avro from 'avsc'; export const schema: any = { type: 'record', name: 'InteractionBatch', namespace: 'com.useoptic.types.capture', fields: [ { name: 'groupingIdentifiers', type: { type: 'record', name: 'GroupingIden...
tony-aq/optic
workspaces/ui-v2/src/pages/changelog/ChangelogPages.tsx
<gh_stars>100-1000 import React from 'react'; import { Switch, Redirect, Route, useParams } from 'react-router-dom'; import { useChangelogPages, useChangelogEndpointPageLink, } from '<src>/components/navigation/Routes'; import { useFetchEndpoints } from '<src>/hooks/useFetchEndpoints'; import { ChangelogListPage }...
tony-aq/optic
workspaces/spectacle/src/openapi/json-schema.ts
<reponame>tony-aq/optic<gh_stars>100-1000 export async function jsonSchemaFromShapeId( spectacle: any, shapeId: string ): Promise<JsonSchema> { const shape = await queryForShape(spectacle, shapeId); // We ignore Undefined here because we check in when dealing with Object const shapeChoices = shape.data.shape...
tony-aq/optic
workspaces/spectacle/src/main.ts
import { makeSpectacle } from './index'; import * as OpticEngine from '@useoptic/optic-engine-wasm'; import { InMemoryOpticContextBuilder } from './in-memory'; import * as fs from 'fs'; function loadExampleSpec(name: string): any[] { return JSON.parse( fs .readFileSync(`./workspaces/spectacle/examples/${n...
tony-aq/optic
workspaces/ui-v2/src/utils/pathMatcher.ts
export type PathComponentAuthoring = { index: number; name: string; originalName: string; isParameter: boolean; }; export function urlStringToPathComponents( url: string ): PathComponentAuthoring[] { const components: PathComponentAuthoring[] = url .split('/') .map((name, index) => { return {...
tony-aq/optic
workspaces/ui-v2/src/constants/index.ts
export * from './SupportLinks';
tony-aq/optic
workspaces/ui-v2/src/utils/__tests__/pathMatcher.test.ts
import { pathMatcher, urlStringToPathComponents } from '../pathMatcher'; test('generates a matcher expression from a path', () => { const matcher = pathMatcher( urlStringToPathComponents('/api/123/hello').map((part) => { if (part.name === '123') { part.isParameter = true; } return part;...
tony-aq/optic
workspaces/spectacle/src/helpers.ts
import { shapes, endpoints } from '@useoptic/graph-lib'; import { CQRSCommand, JsonType } from '@useoptic/optic-domain'; import { IOpticEngine, IOpticEngineIdGenerationStrategy } from './types'; export function buildEndpointsGraph(spec: any, opticEngine: any) { const serializedGraph = JSON.parse( opticEngine.get...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/components/DiffAccessoryNavigation.tsx
<gh_stars>100-1000 import React from 'react'; import { makeStyles } from '@material-ui/styles'; import { Theme } from '@material-ui/core/styles'; import { useHistory } from 'react-router-dom'; import { OpticBlueReadable } from '<src>/styles'; import { Button, LinearProgress, Typography } from '@material-ui/core'; impor...
tony-aq/optic
workspaces/ui-v2/src/components/HttpBodyPanel.tsx
<reponame>tony-aq/optic import React, { FC, useEffect, useRef } from 'react'; import { IShapeRenderer } from '<src>/types'; import { ShapeRenderer } from './ShapeRenderer'; import { Panel } from './Panel'; type HttpBodyPanelProps = { shapes: IShapeRenderer[]; location: string; selectedFieldId?: string | null; ...
tony-aq/optic
workspaces/api-checks/src/types.ts
export type CheckFunction = ({ endpointChange, endpoint, }: { endpointChange: any; endpoint: any; }) => Promise<string | undefined>; export type EndpointChangeChecksOptions = { sinceBatchCommitId: string; spectacle: any; }; export type CheckFunctionRegistry = { added: CheckFunction[]; updated: CheckFu...
tony-aq/optic
workspaces/ui-v2/src/hooks/useFetchEndpoints.ts
import { useEffect } from 'react'; import { useSpectacleContext } from '<src>/contexts/spectacle-provider'; import { endpointActions, useAppDispatch } from '<src>/store'; export const useFetchEndpoints = (batchId?: string) => { const dispatch = useAppDispatch(); const spectacle = useSpectacleContext(); useEffec...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/components/HighlightedLocation.tsx
<gh_stars>100-1000 import React, { FC } from 'react'; import { DiffLocation } from '<src>/lib/parse-diff'; import { OpticBlueReadable, SubtleBlueBackground } from '<src>/styles'; //@ts-ignore import ScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed'; import { makeStyles } from '@material-ui/core'; import cl...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/ReviewDiffPages.tsx
<reponame>tony-aq/optic import React, { useEffect, useMemo, useState } from 'react'; import { Redirect, Route, Switch } from 'react-router-dom'; import { unwrapResult } from '@reduxjs/toolkit'; import { useDiffEnvironmentsRoot, useDiffForEndpointLink, useDiffReviewCapturePageLink, useDiffReviewPageLink, useD...
tony-aq/optic
workspaces/ui-v2/src/components/ShapeRenderer/ShapeRenderContext.tsx
<filename>workspaces/ui-v2/src/components/ShapeRenderer/ShapeRenderContext.tsx import React, { useEffect } from 'react'; import { IShapeRenderer } from '<src>/types'; import { useContext, useState, useCallback } from 'react'; import { DepthStore } from './DepthContext'; import { OneOfTabsProps } from './OneOfTabs'; ty...
tony-aq/optic
workspaces/ui-v2/src/pages/docs/EndpointRootPage.tsx
<reponame>tony-aq/optic import React, { FC, useCallback, useEffect, useState } from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; import { Button, LinearProgress, makeStyles } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import { Delete as DeleteIcon, Undo as UndoIcon...
tony-aq/optic
workspaces/spectacle/src/openapi/index.ts
import { OperationDefinitionNode } from 'graphql'; import { JsonSchema, jsonSchemaFromShapeId } from './json-schema'; export async function generateOpenApi(spectacle: any) { const requests = await spectacle.queryWrapper({ query: `{ requests { id pathId pathComponents { nam...
tony-aq/optic
workspaces/ui-v2/src/utils/dateFormat.ts
<filename>workspaces/ui-v2/src/utils/dateFormat.ts // @ts-ignore import TimeAgo from 'javascript-time-ago'; // @ts-ignore import en from 'javascript-time-ago/locale/en'; TimeAgo.addLocale(en); const timeAgo = new TimeAgo('en-US'); export const formatTimeAgo = (date: Date) => { return timeAgo.format(new Date(date));...
tony-aq/optic
workspaces/ui-v2/src/pages/diffs/hooks/useEndpointDiffs.ts
<gh_stars>100-1000 import { useSharedDiffContext } from '../contexts/SharedDiffContext'; import { EndpointDiffGrouping } from '../contexts/SharedDiffState'; export function useEndpointDiffs( pathId: string, method: string ): EndpointDiffGrouping { const diffState = useSharedDiffContext(); const endpoint = dif...
tony-aq/optic
workspaces/ui-v2/src/pages/docs/components/EndpointTOC.tsx
<gh_stars>100-1000 import * as React from 'react'; import makeStyles from '@material-ui/styles/makeStyles'; import { getReasonPhrase } from 'http-status-codes'; import { List, ListItem, Typography } from '@material-ui/core'; import { selectors } from '<src>/store'; import { SubtleGreyBackground } from '<src>/styles'; i...
tony-aq/optic
workspaces/ui-v2/src/contexts/spectacle-provider.tsx
import React, { useCallback, useContext, useEffect, useState } from 'react'; import { SpectacleInput, IForkableSpectacle } from '@useoptic/spectacle'; import * as Sentry from '@sentry/react'; import { AsyncStatus } from '<src>/types'; export const SpectacleContext = React.createContext<IForkableSpectacle | null>( nu...
tony-aq/optic
workspaces/ui-v2/src/store/paths/thunks.ts
import { createAsyncThunk } from '@reduxjs/toolkit'; import * as Sentry from '@sentry/react'; import { IForkableSpectacle } from '@useoptic/spectacle'; import { IPath } from '<src>/types'; export const AllPathsQuery = `{ paths { parentPathId absolutePathPattern absolutePathPatternWithParameterNames ...
tony-aq/optic
workspaces/ui-v2/src/components/ShapeTypeSummary.tsx
<filename>workspaces/ui-v2/src/components/ShapeTypeSummary.tsx import React, { FC } from 'react'; import { JsonType } from '@useoptic/optic-domain'; import { IShapeRenderer } from '<src>/types'; import * as Theme from '<src>/styles/theme'; export const ShapeTypeSummary: FC<{ shapes: IShapeRenderer[]; required: bo...
tony-aq/optic
workspaces/ui-v2/src/pages/changelog/components/index.ts
<gh_stars>100-1000 export * from './ChangelogAccessoryNavigation'; export * from './ValidateBatchId';
tony-aq/optic
workspaces/cli-server/src/routers/capture-router.ts
<filename>workspaces/cli-server/src/routers/capture-router.ts import express from 'express'; import bodyParser from 'body-parser'; import Bottleneck from 'bottleneck'; import { IdGenerator } from '@useoptic/cli-shared'; import { CaptureId } from '@useoptic/saas-types'; import { IInteractionPointerConverter, LocalCa...
tony-aq/optic
workspaces/spectacle/test/openapi/index.ts
<gh_stars>100-1000 // @ts-ignore import Tap from 'tap'; import { makeSpectacle } from '../../src'; import { loadEvents } from '../utils'; import { InMemoryOpticContextBuilder } from '../../src/in-memory'; import * as OpticEngine from '../../../optic-engine-wasm/build'; import { generateOpenApi } from '../../src/openapi...
tony-aq/optic
workspaces/optic-domain/tests/streams/spec-events.ts
import Tap from 'tap'; import * as AT from '../../src/async-tools'; import { SpecEvents } from '../../src/streams'; Tap.test('SpecEvents.takeUntilBatch', async (test) => { await test.test('takes events until a batch commit id', async (t) => { const exampleEvents = createExampleEvents(); const batchesUntil = ...
tony-aq/optic
workspaces/changelog/test/index.ts
import * as fs from 'fs'; import Tap from 'tap'; import { generateEndpointChanges } from '../src'; function loadSpecs(scenario: string) { return { initialSpec: JSON.parse( fs.readFileSync(`./test/specs/${scenario}/initial.json`).toString(), ), newSpec: JSON.parse( fs.readFileSync(`./test/spec...