From 917fa4cf3a51bac5d26ac35f218582a902ef1341 Mon Sep 17 00:00:00 2001 From: Rohin Bhargava Date: Wed, 23 Oct 2024 18:05:12 -0400 Subject: [PATCH] fix: disconnect after 20 messages to illustrate how websockets work (#1694) --- .../definition/docs/v1/commons/commons.yml | 5 - .../fdr/definition/docs/v1/db/__package__.yml | 3 - .../definition/docs/v1/read/__package__.yml | 3 - .../definition/docs/v1/write/__package__.yml | 3 - .../navigation/latest/__package__.yml | 1 + .../definition/navigation/v1/__package__.yml | 1 + .../src/definition-object-factory.ts | 1 - .../commons/types/PlaygroundConfig.ts | 7 - .../commons/resources/commons/types/index.ts | 1 - .../v1/resources/db/types/DocsDbConfig.ts | 1 - .../v1/resources/read/types/DocsConfig.ts | 1 - .../v1/resources/write/client/Client.ts | 3 - .../client/requests/RegisterDocsRequest.ts | 3 - .../v1/resources/write/types/DocsConfig.ts | 1 - .../v2/resources/write/client/Client.ts | 3 - .../client/requests/RegisterDocsRequest.ts | 3 - .../latest/types/PlaygroundSettings.ts | 1 + .../resources/v1/types/PlaygroundSettings.ts | 1 + .../db/convertDocsDefinitionToDb.ts | 1 - .../read/convertDbDocsConfigToRead.ts | 1 - .../web-socket/WebSocketMessages.scss | 7 +- .../web-socket/WebSocketMessages.tsx | 146 ++++++++++-------- .../src/playground/PlaygroundWebSocket.tsx | 33 +++- .../playground/PlaygroundWebSocketContent.tsx | 4 - .../PlaygroundWebSocketSessionForm.tsx | 10 +- .../src/__test__/local/services/docs.test.ts | 1 - .../__test__/local/services/docsCache.test.ts | 1 - .../__test__/local/services/snippets.test.ts | 3 - .../services/snippetsByEndpointId.test.ts | 1 - ...enerateAlgoliaSearchRecordsForDocs.test.ts | 1 - .../commons/types/PlaygroundConfig.d.ts | 6 - .../commons/types/PlaygroundConfig.js | 4 - .../resources/commons/types/index.d.ts | 1 - .../commons/resources/commons/types/index.js | 1 - .../v1/resources/db/types/DocsDbConfig.d.ts | 1 - .../v1/resources/read/types/DocsConfig.d.ts | 1 - .../v1/resources/write/types/DocsConfig.d.ts | 1 - .../latest/types/PlaygroundSettings.d.ts | 1 + .../v1/types/PlaygroundSettings.d.ts | 1 + servers/fdr/src/healthchecks/checkRedis.ts | 1 - 40 files changed, 125 insertions(+), 144 deletions(-) delete mode 100644 packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.ts delete mode 100644 servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.d.ts delete mode 100644 servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.js diff --git a/fern/apis/fdr/definition/docs/v1/commons/commons.yml b/fern/apis/fdr/definition/docs/v1/commons/commons.yml index deb7a75c7c..a340d465a3 100644 --- a/fern/apis/fdr/definition/docs/v1/commons/commons.yml +++ b/fern/apis/fdr/definition/docs/v1/commons/commons.yml @@ -328,11 +328,6 @@ types: - fallback - optional - # Playground - PlaygroundConfig: - properties: - oauth: optional - # Deprecated ThemedFileId: diff --git a/fern/apis/fdr/definition/docs/v1/db/__package__.yml b/fern/apis/fdr/definition/docs/v1/db/__package__.yml index c7e3520743..7520f5a809 100644 --- a/fern/apis/fdr/definition/docs/v1/db/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/db/__package__.yml @@ -83,9 +83,6 @@ types: css: optional js: optional - # playground - playground: optional - # deprecated logo: type: optional diff --git a/fern/apis/fdr/definition/docs/v1/read/__package__.yml b/fern/apis/fdr/definition/docs/v1/read/__package__.yml index 8888134506..dddd67cff5 100644 --- a/fern/apis/fdr/definition/docs/v1/read/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/read/__package__.yml @@ -119,9 +119,6 @@ types: css: optional js: optional - # playground - playground: optional - # deprecated # backgroundImage: # type: optional diff --git a/fern/apis/fdr/definition/docs/v1/write/__package__.yml b/fern/apis/fdr/definition/docs/v1/write/__package__.yml index c4a8a9deb6..a4c0be7e1b 100644 --- a/fern/apis/fdr/definition/docs/v1/write/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/write/__package__.yml @@ -117,9 +117,6 @@ types: css: optional js: optional - # playground - playground: optional - # deprecated backgroundImage: optional logoV2: optional diff --git a/fern/apis/fdr/definition/navigation/latest/__package__.yml b/fern/apis/fdr/definition/navigation/latest/__package__.yml index 1b39192128..334fbb3b9a 100644 --- a/fern/apis/fdr/definition/navigation/latest/__package__.yml +++ b/fern/apis/fdr/definition/navigation/latest/__package__.yml @@ -254,6 +254,7 @@ types: A list of environment IDs that are allowed to be used in the playground. If not provided, all environments are allowed. And if the provided list is empty, the playground should be disabled. button: optional + limit-websocket-messages-per-connection: optional PlaygroundButtonSettings: properties: diff --git a/fern/apis/fdr/definition/navigation/v1/__package__.yml b/fern/apis/fdr/definition/navigation/v1/__package__.yml index 89efdfa432..7be1037ffb 100644 --- a/fern/apis/fdr/definition/navigation/v1/__package__.yml +++ b/fern/apis/fdr/definition/navigation/v1/__package__.yml @@ -254,6 +254,7 @@ types: A list of environment IDs that are allowed to be used in the playground. If not provided, all environments are allowed. And if the provided list is empty, the playground should be disabled. button: optional + limit-websocket-messages-per-connection: optional PlaygroundButtonSettings: properties: diff --git a/packages/commons/fdr-utils/src/definition-object-factory.ts b/packages/commons/fdr-utils/src/definition-object-factory.ts index 0d301cf35f..5455366756 100644 --- a/packages/commons/fdr-utils/src/definition-object-factory.ts +++ b/packages/commons/fdr-utils/src/definition-object-factory.ts @@ -37,7 +37,6 @@ export class DefinitionObjectFactory { integrations: undefined, css: undefined, js: undefined, - playground: undefined, }, search: { type: "singleAlgoliaIndex", diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.ts deleted file mode 100644 index 3c201cb5a8..0000000000 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface PlaygroundConfig { - oauth: boolean | undefined; -} diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts index fe0eea23a7..2d510b2e0e 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts @@ -45,7 +45,6 @@ export * from "./CustomFontConfig"; export * from "./CustomFontConfigVariant"; export * from "./FontStyle"; export * from "./FontDisplay"; -export * from "./PlaygroundConfig"; export * from "./ThemedFileId"; export * from "./ColorsConfig"; export * from "./ColorsConfigV2"; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts index f132f19348..2e9a8caba7 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts @@ -25,7 +25,6 @@ export interface DocsDbConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; logo: FernRegistry.FileId | undefined; logoV2: FernRegistry.docs.v1.commons.ThemedFileId | undefined; colors: FernRegistry.docs.v1.commons.ColorsConfig | undefined; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts index 96a53fe57b..a549e434ee 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts @@ -24,5 +24,4 @@ export interface DocsConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; } diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/Client.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/Client.ts index a2f6b15ec1..e966bcacec 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/Client.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/Client.ts @@ -362,9 +362,6 @@ export class Write { * "key": "value" * }] * }, - * playground: { - * oauth: true - * }, * backgroundImage: FernRegistry.FileId("string"), * logoV2: { * dark: FernRegistry.FileId("string"), diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/requests/RegisterDocsRequest.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/requests/RegisterDocsRequest.ts index 165ee65d65..9004b126c6 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/requests/RegisterDocsRequest.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/client/requests/RegisterDocsRequest.ts @@ -284,9 +284,6 @@ import * as FernRegistry from "../../../../../../../../index"; * "key": "value" * }] * }, - * playground: { - * oauth: true - * }, * backgroundImage: FernRegistry.FileId("string"), * logoV2: { * dark: FernRegistry.FileId("string"), diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts index 55c12788c4..a5be303dd5 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts @@ -24,7 +24,6 @@ export interface DocsConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; backgroundImage: FernRegistry.FileId | undefined; logoV2: FernRegistry.docs.v1.commons.ThemedFileId | undefined; logo: FernRegistry.FileId | undefined; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/Client.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/Client.ts index cc955c9a0a..bc25cef97d 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/Client.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/Client.ts @@ -464,9 +464,6 @@ export class Write { * "key": "value" * }] * }, - * playground: { - * oauth: true - * }, * backgroundImage: FernRegistry.FileId("string"), * logoV2: { * dark: FernRegistry.FileId("string"), diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/requests/RegisterDocsRequest.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/requests/RegisterDocsRequest.ts index 165ee65d65..9004b126c6 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/requests/RegisterDocsRequest.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v2/resources/write/client/requests/RegisterDocsRequest.ts @@ -284,9 +284,6 @@ import * as FernRegistry from "../../../../../../../../index"; * "key": "value" * }] * }, - * playground: { - * oauth: true - * }, * backgroundImage: FernRegistry.FileId("string"), * logoV2: { * dark: FernRegistry.FileId("string"), diff --git a/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.ts b/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.ts index d7f0e15c37..7312d680fd 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.ts @@ -11,4 +11,5 @@ export interface PlaygroundSettings { */ environments: FernRegistry.EnvironmentId[] | undefined; button: FernRegistry.navigation.latest.PlaygroundButtonSettings | undefined; + "limit-websocket-messages-per-connection": number | undefined; } diff --git a/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.ts b/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.ts index 717ad1345b..885c7609e8 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.ts @@ -11,4 +11,5 @@ export interface PlaygroundSettings { */ environments: FernRegistry.EnvironmentId[] | undefined; button: FernRegistry.navigation.v1.PlaygroundButtonSettings | undefined; + "limit-websocket-messages-per-connection": number | undefined; } diff --git a/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts b/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts index 08079ae48b..0a2f3bdacd 100644 --- a/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts +++ b/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts @@ -112,7 +112,6 @@ export function convertDocsDefinitionToDb({ defaultLanguage: writeShape.config.defaultLanguage, analyticsConfig: writeShape.config.analyticsConfig, announcement: writeShape.config.announcement, - playground: writeShape.config.playground, }, pages: writeShape.pages, jsFiles: writeShape.jsFiles, diff --git a/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts b/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts index 51ca7ff9f0..f943bef17b 100644 --- a/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts +++ b/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts @@ -26,7 +26,6 @@ export function convertDbDocsConfigToRead({ dbShape }: { dbShape: DocsV1Db.DocsD defaultLanguage: dbShape.defaultLanguage, analyticsConfig: dbShape.analyticsConfig, announcement: dbShape.announcement, - playground: dbShape.playground, }; } diff --git a/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.scss b/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.scss index 9746a112b7..788ab16d26 100644 --- a/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.scss +++ b/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.scss @@ -4,7 +4,8 @@ @apply sticky top-0 z-10 backdrop-blur; .fern-web-socket-client, - .fern-web-socket-server { + .fern-web-socket-server, + .fern-web-socket-end-sample { @apply inline-block shrink-0 rounded-full p-0.5; } @@ -16,6 +17,10 @@ @apply t-accent-aaa bg-tag-primary; } + .fern-web-socket-end-sample { + @apply t-danger bg-tag-danger; + } + .fern-web-socket-type { @apply flex-1 inline-flex justify-end; diff --git a/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.tsx b/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.tsx index 42ec302333..e79de8b9a2 100644 --- a/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.tsx +++ b/packages/ui/app/src/api-reference/web-socket/WebSocketMessages.tsx @@ -2,13 +2,14 @@ import { APIV1Read } from "@fern-api/fdr-sdk/client/types"; import { CopyToClipboardButton } from "@fern-ui/components"; import * as Accordion from "@radix-ui/react-accordion"; import cn from "clsx"; -import { ArrowDown, ArrowUp, NavArrowDown } from "iconoir-react"; +import { ArrowDown, ArrowUp, NavArrowDown, Xmark } from "iconoir-react"; import { FC } from "react"; +import { Virtuoso } from "react-virtuoso"; import { FernSyntaxHighlighter } from "../../syntax-highlighting/FernSyntaxHighlighter"; export interface WebSocketMessage { type: string | undefined; - origin: APIV1Read.WebSocketMessageOrigin | undefined; + origin: APIV1Read.WebSocketMessageOrigin | "endSample" | undefined; displayName: string | undefined; data: unknown | undefined; // shape: APIV1Read.WebSocketMessageBodyShape; @@ -21,7 +22,10 @@ interface WebSocketMessagesProps { export const WebSocketMessages: FC = ({ messages }) => { return ( - + {messages.length === 0 && (
@@ -30,71 +34,83 @@ export const WebSocketMessages: FC = ({ messages }) => {
)} - {messages.map((message, index) => { - return ( - - - {message.origin === APIV1Read.WebSocketMessageOrigin.Client ? ( - - - - ) : message.origin === APIV1Read.WebSocketMessageOrigin.Server ? ( - - - - ) : null} - {JSON.stringify(message.data)} - {message.displayName != null || message.type != null ? ( - - {message.displayName ?? message.type} - - ) : null} + { + return ( + + + {message.origin === APIV1Read.WebSocketMessageOrigin.Client ? ( + + + + ) : message.origin === APIV1Read.WebSocketMessageOrigin.Server ? ( + + + + ) : message.origin === "endSample" ? ( + + + + ) : null} + {JSON.stringify(message.data)} + {message.displayName != null || message.type != null ? ( + + + {message.displayName ?? message.type} + + + ) : null} - JSON.stringify(message.data, null, 2)} - onClick={(e) => e.stopPropagation()} - /> + JSON.stringify(message.data, null, 2)} + onClick={(e) => e.stopPropagation()} + /> - - - -
- -
-
-
- - ); - })} + + +
+ +
+
+
+ + ); + }} + followOutput={"smooth"} + /> ); }; diff --git a/packages/ui/app/src/playground/PlaygroundWebSocket.tsx b/packages/ui/app/src/playground/PlaygroundWebSocket.tsx index 6557caebb4..ece10e22a0 100644 --- a/packages/ui/app/src/playground/PlaygroundWebSocket.tsx +++ b/packages/ui/app/src/playground/PlaygroundWebSocket.tsx @@ -21,25 +21,41 @@ interface PlaygroundWebSocketProps { export const PlaygroundWebSocket: FC = ({ context }): ReactElement => { const [formState, setFormState] = usePlaygroundWebsocketFormState(context); + const websocketMessageLimit = usePlaygroundSettings(context.node.id)?.["limit-websocket-messages-per-connection"]; const [connectedState, setConnectedState] = useState<"opening" | "opened" | "closed">("closed"); - const { messages, pushMessage, clearMessages } = useWebsocketMessages(context.channel.id); + const { pushMessage, clearMessages } = useWebsocketMessages(context.node.id); const [error, setError] = useState(null); + const [activeSessionMessageCount, setActiveSessionMessageCount] = useState(0); const socket = useRef(null); // close the socket when the websocket changes - const prevWebsocket = usePrevious(context.channel); + const prevWebsocket = usePrevious(context.node); useEffect(() => { - if (prevWebsocket.id !== context.channel.id) { + if (prevWebsocket.id !== context.node.id) { socket.current?.close(); setError(null); } - }, [context.channel.id, prevWebsocket.id]); + }, [context.node.id, prevWebsocket.id]); // auto-destroy the socket when the component is unmounted useEffect(() => () => socket.current?.close(), []); + // when we get to 20 messages, close the socket + useEffect(() => { + if (websocketMessageLimit && activeSessionMessageCount >= websocketMessageLimit) { + socket.current?.close(); + setConnectedState("closed"); + pushMessage({ + type: "end", + data: "END OF SAMPLE SESSION", + origin: "endSample", + displayName: undefined, + }); + } + }, [activeSessionMessageCount, pushMessage, websocketMessageLimit]); + const settings = usePlaygroundSettings(); const [baseUrl, environmentId] = usePlaygroundBaseUrl(context.channel); @@ -80,13 +96,17 @@ export const PlaygroundWebSocket: FC = ({ context }): if (data.type === "handshake" && data.status === "connected") { setConnectedState("opened"); resolve(true); - } else if (data.type === "data") { + } else if ( + data.type === "data" && + (!websocketMessageLimit || activeSessionMessageCount < websocketMessageLimit) + ) { pushMessage({ type: "received", data: typeof data.data === "string" ? JSON.parse(data.data) : data.data, origin: "server", displayName: undefined, }); + setActiveSessionMessageCount((m) => m + 1); } }; @@ -97,6 +117,7 @@ export const PlaygroundWebSocket: FC = ({ context }): if (ev.code !== 1000) { setError(ev.reason); } + setActiveSessionMessageCount(0); }; socket.current.onerror = (event) => { @@ -112,6 +133,7 @@ export const PlaygroundWebSocket: FC = ({ context }): formState.queryParameters, formState.headers, pushMessage, + activeSessionMessageCount, ]); const handleSendMessage = useCallback( @@ -180,7 +202,6 @@ export const PlaygroundWebSocket: FC = ({ context }): context={context} formState={formState} setFormState={setFormState} - messages={messages} sendMessage={handleSendMessage} startSesssion={startSession} clearMessages={clearMessages} diff --git a/packages/ui/app/src/playground/PlaygroundWebSocketContent.tsx b/packages/ui/app/src/playground/PlaygroundWebSocketContent.tsx index 459239546c..ea0de8014e 100644 --- a/packages/ui/app/src/playground/PlaygroundWebSocketContent.tsx +++ b/packages/ui/app/src/playground/PlaygroundWebSocketContent.tsx @@ -1,7 +1,6 @@ import type * as ApiDefinition from "@fern-api/fdr-sdk/api-definition"; import type { WebSocketContext } from "@fern-api/fdr-sdk/api-definition"; import { Dispatch, FC, SetStateAction, useEffect, useRef, useState } from "react"; -import { WebSocketMessage } from "../api-reference/web-socket/WebSocketMessages"; import { PlaygroundWebSocketSessionForm } from "./PlaygroundWebSocketSessionForm"; import { PlaygroundWebSocketRequestFormState } from "./types"; @@ -9,7 +8,6 @@ interface PlaygroundWebSocketContentProps { context: WebSocketContext; formState: PlaygroundWebSocketRequestFormState; setFormState: Dispatch>; - messages: WebSocketMessage[]; startSesssion: () => void; clearMessages: () => void; sendMessage: (message: ApiDefinition.WebSocketMessage, data: unknown) => void; @@ -21,7 +19,6 @@ export const PlaygroundWebSocketContent: FC = ( context, formState, setFormState, - messages, sendMessage, startSesssion, clearMessages, @@ -56,7 +53,6 @@ export const PlaygroundWebSocketContent: FC = ( context={context} formState={formState} scrollAreaHeight={scrollAreaHeight} - messages={messages} setFormState={setFormState} sendMessage={sendMessage} startSession={startSesssion} diff --git a/packages/ui/app/src/playground/PlaygroundWebSocketSessionForm.tsx b/packages/ui/app/src/playground/PlaygroundWebSocketSessionForm.tsx index af20890cec..3ee9993a65 100644 --- a/packages/ui/app/src/playground/PlaygroundWebSocketSessionForm.tsx +++ b/packages/ui/app/src/playground/PlaygroundWebSocketSessionForm.tsx @@ -4,10 +4,11 @@ import titleCase from "@fern-api/ui-core-utils/titleCase"; import { FernButton, FernCard, FernScrollArea } from "@fern-ui/components"; import cn from "clsx"; import { Dispatch, FC, SetStateAction, useCallback } from "react"; -import { WebSocketMessage, WebSocketMessages } from "../api-reference/web-socket/WebSocketMessages"; +import { WebSocketMessages } from "../api-reference/web-socket/WebSocketMessages"; import { PlaygroundWebSocketHandshakeForm } from "./PlaygroundWebSocketHandshakeForm"; import { HorizontalSplitPane } from "./VerticalSplitPane"; import { PlaygroundTypeReferenceForm } from "./form/PlaygroundTypeReferenceForm"; +import { useWebsocketMessages } from "./hooks/useWebsocketMessages"; import { PlaygroundWebSocketRequestFormState } from "./types"; interface PlaygroundWebSocketSessionFormProps { @@ -17,7 +18,6 @@ interface PlaygroundWebSocketSessionFormProps { // response: Loadable; // sendRequest: () => void; scrollAreaHeight: number; - messages: WebSocketMessage[]; sendMessage: (message: ApiDefinition.WebSocketMessage, data: unknown) => void; clearMessages: () => void; startSession: () => void; @@ -30,12 +30,13 @@ export const PlaygroundWebSocketSessionForm: FC { + const { messages } = useWebsocketMessages(context.node.id); + const setMessage = useCallback( (message: ApiDefinition.WebSocketMessage, data: unknown) => { setFormState((old) => ({ @@ -130,8 +131,7 @@ export const PlaygroundWebSocketSessionForm: FC
- {/* TODO(rohin): Implement Pagination here */} - +
diff --git a/servers/fdr/src/__test__/local/services/docs.test.ts b/servers/fdr/src/__test__/local/services/docs.test.ts index 33dc2663ea..b0ba04a391 100644 --- a/servers/fdr/src/__test__/local/services/docs.test.ts +++ b/servers/fdr/src/__test__/local/services/docs.test.ts @@ -37,7 +37,6 @@ export const WRITE_DOCS_REGISTER_DEFINITION: DocsV1Write.DocsDefinition = { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, diff --git a/servers/fdr/src/__test__/local/services/docsCache.test.ts b/servers/fdr/src/__test__/local/services/docsCache.test.ts index c82b8e2876..571f623e6d 100644 --- a/servers/fdr/src/__test__/local/services/docsCache.test.ts +++ b/servers/fdr/src/__test__/local/services/docsCache.test.ts @@ -27,7 +27,6 @@ export const WRITE_DOCS_REGISTER_DEFINITION: DocsV1Write.DocsDefinition = { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, diff --git a/servers/fdr/src/__test__/local/services/snippets.test.ts b/servers/fdr/src/__test__/local/services/snippets.test.ts index 833966430e..7a4c6af525 100644 --- a/servers/fdr/src/__test__/local/services/snippets.test.ts +++ b/servers/fdr/src/__test__/local/services/snippets.test.ts @@ -143,7 +143,6 @@ it("get snippets", async () => { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, @@ -306,7 +305,6 @@ it("get Go snippets", async () => { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, @@ -466,7 +464,6 @@ it("get Ruby snippets", async () => { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, diff --git a/servers/fdr/src/__test__/local/services/snippetsByEndpointId.test.ts b/servers/fdr/src/__test__/local/services/snippetsByEndpointId.test.ts index 86dfb81e97..f26d046bc3 100644 --- a/servers/fdr/src/__test__/local/services/snippetsByEndpointId.test.ts +++ b/servers/fdr/src/__test__/local/services/snippetsByEndpointId.test.ts @@ -129,7 +129,6 @@ it("Load snippets by endpoint id", async () => { integrations: undefined, css: undefined, js: undefined, - playground: undefined, backgroundImage: undefined, logoV2: undefined, logo: undefined, diff --git a/servers/fdr/src/__test__/unit-tests/generate-algolia-search-records/testGenerateAlgoliaSearchRecordsForDocs.test.ts b/servers/fdr/src/__test__/unit-tests/generate-algolia-search-records/testGenerateAlgoliaSearchRecordsForDocs.test.ts index fbbdcd8195..4fe0ca55f8 100644 --- a/servers/fdr/src/__test__/unit-tests/generate-algolia-search-records/testGenerateAlgoliaSearchRecordsForDocs.test.ts +++ b/servers/fdr/src/__test__/unit-tests/generate-algolia-search-records/testGenerateAlgoliaSearchRecordsForDocs.test.ts @@ -173,7 +173,6 @@ describe("generateIndexSegmentsForDefinition", () => { integrations: undefined, css: undefined, js: undefined, - playground: undefined, logo: undefined, logoV2: undefined, colors: undefined, diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.d.ts b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.d.ts deleted file mode 100644 index 196c98fb48..0000000000 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -export interface PlaygroundConfig { - oauth: boolean | undefined; -} diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.js b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.js deleted file mode 100644 index 0b46289f5b..0000000000 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/PlaygroundConfig.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -export {}; diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.d.ts b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.d.ts index fe0eea23a7..2d510b2e0e 100644 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.d.ts +++ b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.d.ts @@ -45,7 +45,6 @@ export * from "./CustomFontConfig"; export * from "./CustomFontConfigVariant"; export * from "./FontStyle"; export * from "./FontDisplay"; -export * from "./PlaygroundConfig"; export * from "./ThemedFileId"; export * from "./ColorsConfig"; export * from "./ColorsConfigV2"; diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.js b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.js index fe0eea23a7..2d510b2e0e 100644 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.js +++ b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.js @@ -45,7 +45,6 @@ export * from "./CustomFontConfig"; export * from "./CustomFontConfigVariant"; export * from "./FontStyle"; export * from "./FontDisplay"; -export * from "./PlaygroundConfig"; export * from "./ThemedFileId"; export * from "./ColorsConfig"; export * from "./ColorsConfigV2"; diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.d.ts b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.d.ts index 723ffe07e1..59589e48ea 100644 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.d.ts +++ b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.d.ts @@ -23,7 +23,6 @@ export interface DocsDbConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; logo: FernRegistry.FileId | undefined; logoV2: FernRegistry.docs.v1.commons.ThemedFileId | undefined; colors: FernRegistry.docs.v1.commons.ColorsConfig | undefined; diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.d.ts b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.d.ts index d6d283b373..19f2c6d9f5 100644 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.d.ts +++ b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.d.ts @@ -22,5 +22,4 @@ export interface DocsConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; } diff --git a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.d.ts b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.d.ts index 05f0136c5a..2c9f10b49f 100644 --- a/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.d.ts +++ b/servers/fdr/src/api/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.d.ts @@ -22,7 +22,6 @@ export interface DocsConfig { integrations: FernRegistry.docs.v1.commons.IntegrationsConfig | undefined; css: FernRegistry.docs.v1.commons.CssConfig | undefined; js: FernRegistry.docs.v1.commons.JsConfig | undefined; - playground: FernRegistry.docs.v1.commons.PlaygroundConfig | undefined; backgroundImage: FernRegistry.FileId | undefined; logoV2: FernRegistry.docs.v1.commons.ThemedFileId | undefined; logo: FernRegistry.FileId | undefined; diff --git a/servers/fdr/src/api/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.d.ts b/servers/fdr/src/api/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.d.ts index ab5c31361f..ecf325fa27 100644 --- a/servers/fdr/src/api/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.d.ts +++ b/servers/fdr/src/api/generated/api/resources/navigation/resources/latest/types/PlaygroundSettings.d.ts @@ -9,4 +9,5 @@ export interface PlaygroundSettings { */ environments: FernRegistry.EnvironmentId[] | undefined; button: FernRegistry.navigation.latest.PlaygroundButtonSettings | undefined; + "limit-websocket-messages-per-connection": number | undefined; } diff --git a/servers/fdr/src/api/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.d.ts b/servers/fdr/src/api/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.d.ts index 114aaec52c..e4a5e9fae7 100644 --- a/servers/fdr/src/api/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.d.ts +++ b/servers/fdr/src/api/generated/api/resources/navigation/resources/v1/types/PlaygroundSettings.d.ts @@ -9,4 +9,5 @@ export interface PlaygroundSettings { */ environments: FernRegistry.EnvironmentId[] | undefined; button: FernRegistry.navigation.v1.PlaygroundButtonSettings | undefined; + "limit-websocket-messages-per-connection": number | undefined; } diff --git a/servers/fdr/src/healthchecks/checkRedis.ts b/servers/fdr/src/healthchecks/checkRedis.ts index 9822e6f173..03fc55937b 100644 --- a/servers/fdr/src/healthchecks/checkRedis.ts +++ b/servers/fdr/src/healthchecks/checkRedis.ts @@ -38,7 +38,6 @@ const HEALTHCHECK_DOCS_RESPONSE: CachedDocsResponse = { integrations: undefined, css: undefined, js: undefined, - playground: undefined, }, files: {}, filesV2: {},