From b4df646d120dbd1f661a68f60d4d3b970ae06d87 Mon Sep 17 00:00:00 2001 From: Caido Bot Date: Sat, 11 Apr 2026 00:14:08 +0000 Subject: [PATCH] Update SDK Documentation --- src/reference/sdks/backend/api.md | 28 +++- src/reference/sdks/backend/index.md | 2 +- src/reference/sdks/backend/other.md | 149 ++++++++++++++++++ src/reference/sdks/backend/shared.md | 58 +++++-- src/reference/sdks/frontend/backend.md | 28 +++- src/reference/sdks/frontend/findings.md | 2 +- src/reference/sdks/frontend/index.md | 8 +- .../sdks/frontend/match-and-replace.md | 76 ++++++++- src/reference/sdks/frontend/other.md | 25 +++ src/reference/sdks/frontend/replay.md | 105 +++++------- src/reference/sdks/frontend/utils.md | 38 +++++ src/reference/sdks/frontend/websockets.md | 72 +++++++++ 12 files changed, 488 insertions(+), 103 deletions(-) diff --git a/src/reference/sdks/backend/api.md b/src/reference/sdks/backend/api.md index ed6d9f9..fd5d526 100644 --- a/src/reference/sdks/backend/api.md +++ b/src/reference/sdks/backend/api.md @@ -2,7 +2,7 @@ ### APISDK -> **APISDK**\<`API`, `Events`\> = `object` +> **APISDK**\<`SpecOrAPI`, `Events`\> = `object` The SDK for the API RPC service. @@ -10,23 +10,29 @@ The SDK for the API RPC service. | Type Parameter | Default type | | ------ | ------ | -| `API` | `object` | +| `SpecOrAPI` | `object` | | `Events` | `object` | #### Methods ##### register() -> **register**(`name`: keyof `API`, `callback`: (`sdk`: [`SDK`](index.md#sdk), ...`args`: `any`[]) => `any`): `void` +> **register**\<`K`\>(`name`: `K`, `callback`: [`APICallback`](other.md#apicallback)\<[`ResolvedAPI`](other.md#resolvedapi)\<`SpecOrAPI`\>\[`K`\]\>): `void` Registers a new backend function for the RPC. +###### Type Parameters + +| Type Parameter | +| ------ | +| `K` *extends* `string` \| `number` \| `symbol` | + ###### Parameters | Parameter | Type | | ------ | ------ | -| `name` | keyof `API` | -| `callback` | (`sdk`: [`SDK`](index.md#sdk), ...`args`: `any`[]) => `any` | +| `name` | `K` | +| `callback` | [`APICallback`](other.md#apicallback)\<[`ResolvedAPI`](other.md#resolvedapi)\<`SpecOrAPI`\>\[`K`\]\> | ###### Returns @@ -42,16 +48,22 @@ sdk.api.register("multiply", (sdk: SDK, a: number, b: number) => { ##### send() -> **send**(`event`: keyof `Events`, ...`args`: `any`[]): `void` +> **send**\<`K`\>(`event`: `K`, ...`args`: [`EventParameters`](other.md#eventparameters)\<[`ResolvedEvents`](other.md#resolvedevents)\<`SpecOrAPI`, `Events`\>\[`K`\]\>): `void` Sends an event to the frontend plugin. +###### Type Parameters + +| Type Parameter | +| ------ | +| `K` *extends* `string` \| `number` \| `symbol` | + ###### Parameters | Parameter | Type | | ------ | ------ | -| `event` | keyof `Events` | -| ...`args` | `any`[] | +| `event` | `K` | +| ...`args` | [`EventParameters`](other.md#eventparameters)\<[`ResolvedEvents`](other.md#resolvedevents)\<`SpecOrAPI`, `Events`\>\[`K`\]\> | ###### Returns diff --git a/src/reference/sdks/backend/index.md b/src/reference/sdks/backend/index.md index aa58f0c..468e973 100644 --- a/src/reference/sdks/backend/index.md +++ b/src/reference/sdks/backend/index.md @@ -1,7 +1,7 @@ # @caido/sdk-backend This is the reference for the backend SDK used by backend plugins. -[SDK](#events) is the main interface that provides access to various services and functionalities. +[SDK](other.md#events) is the main interface that provides access to various services and functionalities. ## SDK diff --git a/src/reference/sdks/backend/other.md b/src/reference/sdks/backend/other.md index a0e47b6..a1e856c 100644 --- a/src/reference/sdks/backend/other.md +++ b/src/reference/sdks/backend/other.md @@ -145,6 +145,50 @@ The prepared statement [parameters are bound](https://www.sqlite.org/c3ref/bind_ *** +### AnyFn() + +> **AnyFn** = (...`args`: `any`[]) => [`MaybePromise`](shared.md#maybepromise)\<`any`\> + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| ...`args` | `any`[] | + +#### Returns + +[`MaybePromise`](shared.md#maybepromise)\<`any`\> + +*** + +### AnyVoidFn() + +> **AnyVoidFn** = (...`args`: `any`[]) => [`MaybePromise`](shared.md#maybepromise)\<`void`\> + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| ...`args` | `any`[] | + +#### Returns + +[`MaybePromise`](shared.md#maybepromise)\<`void`\> + +*** + +### APICallback + +> **APICallback**\<`T`\> = `T` *extends* [`AnyFn`](#anyfn) ? (`sdk`: [`SDK`](index.md#sdk), ...`args`: `Parameters`\<`T`\>) => `ReturnType`\<`T`\> : [`InvalidCallbackMessage`](#invalidcallbackmessage) + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + ### Console > **Console** = `object` @@ -276,6 +320,54 @@ The value of the environment variable. *** +### EventParameters + +> **EventParameters**\<`T`\> = `T` *extends* [`AnyVoidFn`](#anyvoidfn) ? `A` : [`InvalidEventParametersMessage`](#invalideventparametersmessage) + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + +### ExactPluginPackageKeys + +> **ExactPluginPackageKeys**\<`T`\> = keyof `T` *extends* [`PluginPackageSpecKey`](#pluginpackagespeckey) ? [`PluginPackageSpecKey`](#pluginpackagespeckey) *extends* keyof `T` ? `unknown` : [`PluginPackageSpecKeyError`](#pluginpackagespeckeyerror) : [`PluginPackageSpecKeyError`](#pluginpackagespeckeyerror) + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + +### InvalidCallbackMessage + +> **InvalidCallbackMessage** = `"Your callback must respect the format (sdk: SDK, ...args: unknown[]) => MaybePromise"` + +*** + +### InvalidEventParametersMessage + +> **InvalidEventParametersMessage** = `"Invalid event parameters"` + +*** + +### MaybePromise + +> **MaybePromise**\<`T`\> = `T` \| `Promise`\<`T`\> + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + ### PageInfo > **PageInfo** = `object` @@ -308,6 +400,63 @@ Information on the current page of paginated data. *** +### PluginPackageSpec + +> **PluginPackageSpec** = `object` + +#### Properties + +##### api + +> **api**: `Record`\<`string`, [`AnyFn`](#anyfn)\> + +##### events + +> **events**: `Record`\<`string`, [`AnyVoidFn`](#anyvoidfn)\> + +##### manifestId + +> **manifestId**: `string` + +*** + +### PluginPackageSpecKey + +> **PluginPackageSpecKey** = keyof [`PluginPackageSpec`](#pluginpackagespec) + +*** + +### PluginPackageSpecKeyError + +> **PluginPackageSpecKeyError** = `"Only manifestId, api and events keys are allowed"` + +*** + +### ResolvedAPI + +> **ResolvedAPI**\<`T`\> = `T` *extends* `object` ? `A` : `T` + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + +### ResolvedEvents + +> **ResolvedEvents**\<`T`, `Events`\> = `T` *extends* `object` ? `A` : `Events` + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | +| `Events` | + +*** + ### Result > **Result** = `object` diff --git a/src/reference/sdks/backend/shared.md b/src/reference/sdks/backend/shared.md index 3efce17..703480f 100644 --- a/src/reference/sdks/backend/shared.md +++ b/src/reference/sdks/backend/shared.md @@ -22,7 +22,7 @@ A cursor for pagination. *** -### DefineAPI +### ~~DefineAPI~~ > **DefineAPI**\<`API`\> = `{ [K in keyof API]: DefineAPICallback }` @@ -50,6 +50,10 @@ export function init(sdk: SDK) { } ``` +#### Deprecated + +Use DefinePluginPackageSpec instead. + *** ### DefineAPICallback @@ -80,7 +84,7 @@ Parser for Plugin backend events callbacks. *** -### DefineEvents +### ~~DefineEvents~~ > **DefineEvents**\<`Events`\> = `{ [K in keyof Events]: DefineEventCallback }` @@ -106,33 +110,57 @@ export function init(sdk: SDK<{}, BackendEvents>) { } ``` +#### Deprecated + +Use DefinePluginPackageSpec instead. + *** -### ID +### DefinePluginPackageSpec -> **ID** = `string` & `object` +> **DefinePluginPackageSpec**\<`TSpec`\> = `TSpec` -A unique identifier. +Define the specification of a Plugin Package. This includes: -#### Type Declaration +- Manifest ID: the unique identifier of the plugin package. +- API: the backend functions that are callable from the frontend plugin. +- Events: the events that the frontend can receive from the backend plugin. -##### \_\_id? +#### Type Parameters -> `optional` **\_\_id**: `never` +| Type Parameter | +| ------ | +| `TSpec` *extends* [`PluginPackageSpec`](other.md#pluginpackagespec) & [`ExactPluginPackageKeys`](other.md#exactpluginpackagekeys)\<`TSpec`\> | + +#### Example + +```typescript +type MyEventData = { id: string; name: string }; + +export type Spec = DefinePluginPackageSpec<{ + manifestId: "myplugin", + api: { + myFunction: (min: number, max: number) => Promise; + }, + events: { + "my-event": (data: MyEventData) => void; + } +}>; +``` *** -### MaybePromise +### ID -> **MaybePromise**\<`T`\> = `T` \| `Promise`\<`T`\> +> **ID** = `string` & `object` -Promise or value. +A unique identifier. -#### Type Parameters +#### Type Declaration -| Type Parameter | -| ------ | -| `T` | +##### \_\_id? + +> `optional` **\_\_id**: `never` *** diff --git a/src/reference/sdks/frontend/backend.md b/src/reference/sdks/frontend/backend.md index 54b83a6..800c374 100644 --- a/src/reference/sdks/frontend/backend.md +++ b/src/reference/sdks/frontend/backend.md @@ -26,7 +26,7 @@ Events emitted by the backend plugin. ### BackendSDK -> **BackendSDK**\<`T`, `E`\> = `{ [K in keyof T]: (args: Parameters) => PromisifiedReturnType }` & `object` +> **BackendSDK**\<`T`, `E`\> = `{ [K in keyof ResolvedAPI]: (args: Parameters[K]>) => PromisifiedReturnType[K]> }` & `object` Utilities to interact with the backend plugin. @@ -34,7 +34,7 @@ Utilities to interact with the backend plugin. ##### onEvent() -> **onEvent**: \<`K`\>(`event`: `K`, `callback`: `E`\[`K`\]) => `object` +> **onEvent**: \<`K`\>(`event`: `K`, `callback`: [`ResolvedEvents`](other.md#resolvedevents)\<`T`, `E`\>\[`K`\]) => `object` Subscribe to a backend event. @@ -42,14 +42,14 @@ Subscribe to a backend event. | Type Parameter | | ------ | -| `K` *extends* keyof `E` | +| `K` *extends* keyof [`ResolvedEvents`](other.md#resolvedevents)\<`T`, `E`\> | ###### Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `event` | `K` | The event to subscribe to. | -| `callback` | `E`\[`K`\] | The callback to call when the event is emitted. | +| `callback` | [`ResolvedEvents`](other.md#resolvedevents)\<`T`, `E`\>\[`K`\] | The callback to call when the event is emitted. | ###### Returns @@ -69,5 +69,23 @@ An object with a `stop` method that can be called to stop listening to the event | Type Parameter | | ------ | -| `T` *extends* [`BackendEndpoints`](#backendendpoints) | +| `T` *extends* [`BackendEndpoints`](#backendendpoints) \| [`BackendSpec`](#backendspec) | | `E` *extends* [`BackendEvents`](#backendevents) | + +*** + +### BackendSpec + +> **BackendSpec** = `object` + +A specification for the backend plugin. + +#### Properties + +##### api + +> **api**: [`BackendEndpoints`](#backendendpoints) + +##### events + +> **events**: [`BackendEvents`](#backendevents) diff --git a/src/reference/sdks/frontend/findings.md b/src/reference/sdks/frontend/findings.md index 2cf77b3..31e8767 100644 --- a/src/reference/sdks/frontend/findings.md +++ b/src/reference/sdks/frontend/findings.md @@ -4,7 +4,7 @@ > **Finding** = `object` -Represents a [https://docs.caido.io/reference/features/logging/findings\|Finding](https://docs.caido.io/reference/features/logging/findings|Finding). +Represents a [https://docs.caido.io/app/quickstart/findings.html\|Finding](https://docs.caido.io/app/quickstart/findings.html|Finding). #### Properties diff --git a/src/reference/sdks/frontend/index.md b/src/reference/sdks/frontend/index.md index 643d174..0b22739 100644 --- a/src/reference/sdks/frontend/index.md +++ b/src/reference/sdks/frontend/index.md @@ -15,7 +15,7 @@ Utilities for frontend plugins. | Type Parameter | Default type | | ------ | ------ | -| `T` *extends* [`BackendEndpoints`](backend.md#backendendpoints) | `Record`\<`string`, `never`\> | +| `T` *extends* [`BackendEndpoints`](backend.md#backendendpoints) \| [`BackendSpec`](backend.md#backendspec) | `Record`\<`string`, `never`\> | | `E` *extends* [`BackendEvents`](backend.md#backendevents) | `Record`\<`string`, `never`\> | #### Properties @@ -194,6 +194,12 @@ Utilities to interact with frontend-plugin storage. Utilities to create UI components. +##### websocket + +> **websocket**: [`WebsocketSDK`](websockets.md#websocketsdk) + +Utilities to interact with the Websocket page. + ##### window > **window**: [`WindowSDK`](window.md#windowsdk) diff --git a/src/reference/sdks/frontend/match-and-replace.md b/src/reference/sdks/frontend/match-and-replace.md index f6bf36f..28e37c6 100644 --- a/src/reference/sdks/frontend/match-and-replace.md +++ b/src/reference/sdks/frontend/match-and-replace.md @@ -496,6 +496,36 @@ An operation to update the response status code. *** +### MatchReplaceOperationWebsocket + +> **MatchReplaceOperationWebsocket** = [`KeepOperation`](other.md#keepoperation)\<[`MatchReplaceOperationWebsocketRaw`](#matchreplaceoperationwebsocketraw)\> + +An operation for the response websocket section. + +*** + +### MatchReplaceOperationWebsocketRaw + +> **MatchReplaceOperationWebsocketRaw** = `object` + +A raw operation for the response websocket section. + +#### Properties + +##### kind + +> **kind**: `"OperationWebsocketRaw"` + +##### matcher + +> **matcher**: [`MatchReplaceMatcherRaw`](#matchreplacematcherraw) + +##### replacer + +> **replacer**: [`MatchReplaceReplacer`](#matchreplacereplacer) + +*** + ### MatchReplacePageContext > **MatchReplacePageContext** = `object` @@ -712,10 +742,10 @@ Create a rule. | Parameter | Type | Description | | ------ | ------ | ------ | -| `options` | \{ `collectionId`: [`ID`](utils.md#id); `name`: `string`; `query`: [`HTTPQL`](utils.md#httpql); `section`: [`MatchReplaceSection`](#matchreplacesection); `sources`: [`Source`](#source)[]; \} | The options for the rule. | +| `options` | \{ `collectionId`: [`ID`](utils.md#id); `name`: `string`; `query`: [`QueryInput`](utils.md#queryinput); `section`: [`MatchReplaceSection`](#matchreplacesection); `sources`: [`Source`](#source)[]; \} | The options for the rule. | | `options.collectionId` | [`ID`](utils.md#id) | The ID of the collection the rule belongs to. | | `options.name` | `string` | The name of the rule. | -| `options.query` | [`HTTPQL`](utils.md#httpql) | The HTTPQL query to match the rule against. | +| `options.query` | [`QueryInput`](utils.md#queryinput) | The query to match the rule against. | | `options.section` | [`MatchReplaceSection`](#matchreplacesection) | - | | `options.sources` | [`Source`](#source)[] | The sources the rule belongs to. | @@ -893,9 +923,9 @@ Update a rule. | Parameter | Type | Description | | ------ | ------ | ------ | | `id` | [`ID`](utils.md#id) | The ID of the rule. | -| `options` | \{ `name`: `string`; `query?`: [`HTTPQL`](utils.md#httpql); `section`: [`MatchReplaceSection`](#matchreplacesection); `sources`: [`Source`](#source)[]; \} | The new values for the rule. | +| `options` | \{ `name`: `string`; `query?`: [`QueryInput`](utils.md#queryinput); `section`: [`MatchReplaceSection`](#matchreplacesection); `sources`: [`Source`](#source)[]; \} | The new values for the rule. | | `options.name` | `string` | The new name of the rule. | -| `options.query?` | [`HTTPQL`](utils.md#httpql) | The new HTTPQL query of the rule. | +| `options.query?` | [`QueryInput`](utils.md#queryinput) | The new query of the rule. | | `options.section` | [`MatchReplaceSection`](#matchreplacesection) | The new section of the rule. | | `options.sources` | [`Source`](#source)[] | The new sources of the rule. | @@ -907,7 +937,7 @@ Update a rule. ### MatchReplaceSection -> **MatchReplaceSection** = [`MatchReplaceSectionRequestAll`](#matchreplacesectionrequestall) \| [`MatchReplaceSectionRequestBody`](#matchreplacesectionrequestbody) \| [`MatchReplaceSectionRequestFirstLine`](#matchreplacesectionrequestfirstline) \| [`MatchReplaceSectionRequestHeader`](#matchreplacesectionrequestheader) \| [`MatchReplaceSectionRequestMethod`](#matchreplacesectionrequestmethod) \| [`MatchReplaceSectionRequestPath`](#matchreplacesectionrequestpath) \| [`MatchReplaceSectionRequestQuery`](#matchreplacesectionrequestquery) \| [`MatchReplaceSectionRequestSNI`](#matchreplacesectionrequestsni) \| [`MatchReplaceSectionResponseAll`](#matchreplacesectionresponseall) \| [`MatchReplaceSectionResponseBody`](#matchreplacesectionresponsebody) \| [`MatchReplaceSectionResponseFirstLine`](#matchreplacesectionresponsefirstline) \| [`MatchReplaceSectionResponseHeader`](#matchreplacesectionresponseheader) \| [`MatchReplaceSectionResponseStatusCode`](#matchreplacesectionresponsestatuscode) +> **MatchReplaceSection** = [`MatchReplaceSectionRequestAll`](#matchreplacesectionrequestall) \| [`MatchReplaceSectionRequestBody`](#matchreplacesectionrequestbody) \| [`MatchReplaceSectionRequestFirstLine`](#matchreplacesectionrequestfirstline) \| [`MatchReplaceSectionRequestHeader`](#matchreplacesectionrequestheader) \| [`MatchReplaceSectionRequestMethod`](#matchreplacesectionrequestmethod) \| [`MatchReplaceSectionRequestPath`](#matchreplacesectionrequestpath) \| [`MatchReplaceSectionRequestQuery`](#matchreplacesectionrequestquery) \| [`MatchReplaceSectionRequestSNI`](#matchreplacesectionrequestsni) \| [`MatchReplaceSectionResponseAll`](#matchreplacesectionresponseall) \| [`MatchReplaceSectionResponseBody`](#matchreplacesectionresponsebody) \| [`MatchReplaceSectionResponseFirstLine`](#matchreplacesectionresponsefirstline) \| [`MatchReplaceSectionResponseHeader`](#matchreplacesectionresponseheader) \| [`MatchReplaceSectionResponseStatusCode`](#matchreplacesectionresponsestatuscode) \| [`MatchReplaceSectionResponseWebsocket`](#matchreplacesectionresponsewebsocket) \| [`MatchReplaceSectionRequestWebsocket`](#matchreplacesectionrequestwebsocket) A discriminated union of all possible match and replace sections. @@ -1057,6 +1087,24 @@ A section for the request SNI. *** +### MatchReplaceSectionRequestWebsocket + +> **MatchReplaceSectionRequestWebsocket** = `object` + +A section for the request websocket. + +#### Properties + +##### kind + +> **kind**: `"SectionRequestWebsocket"` + +##### operation + +> **operation**: [`MatchReplaceOperationWebsocket`](#matchreplaceoperationwebsocket) + +*** + ### MatchReplaceSectionResponseAll > **MatchReplaceSectionResponseAll** = `object` @@ -1147,6 +1195,24 @@ A section for the response status code. *** +### MatchReplaceSectionResponseWebsocket + +> **MatchReplaceSectionResponseWebsocket** = `object` + +A section for the response websocket. + +#### Properties + +##### kind + +> **kind**: `"SectionResponseWebsocket"` + +##### operation + +> **operation**: [`MatchReplaceOperationWebsocket`](#matchreplaceoperationwebsocket) + +*** + ### MatchReplaceSlotContent > **MatchReplaceSlotContent** = `object` diff --git a/src/reference/sdks/frontend/other.md b/src/reference/sdks/frontend/other.md index c3db7ec..759198b 100644 --- a/src/reference/sdks/frontend/other.md +++ b/src/reference/sdks/frontend/other.md @@ -131,6 +131,31 @@ A unique command identifier. *** +### ResolvedAPI + +> **ResolvedAPI**\<`T`\> = `T` *extends* `object` ? `A` : `T` + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +*** + +### ResolvedEvents + +> **ResolvedEvents**\<`T`, `E`\> = `T` *extends* `object` ? `A` : `E` + +#### Type Parameters + +| Type Parameter | +| ------ | +| `T` | +| `E` | + +*** + ### Routes > **Routes** = *typeof* [`Routes`](navigation.md#routes)\[keyof *typeof* [`Routes`](#routes-1)\] diff --git a/src/reference/sdks/frontend/replay.md b/src/reference/sdks/frontend/replay.md index de72144..58a4cb2 100644 --- a/src/reference/sdks/frontend/replay.md +++ b/src/reference/sdks/frontend/replay.md @@ -1,5 +1,40 @@ # Replay +### ConnectionInfo + +> **ConnectionInfo** = `object` + +The connection information to use for the request. + +#### Properties + +##### host + +> **host**: `string` + +The host to use for the request. + +##### isTLS + +> **isTLS**: `boolean` + +Whether the request is TLS. + +##### port + +> **port**: `number` + +The port to use for the request. + +##### SNI? + +> `optional` **SNI**: `string` + +The SNI to use for the request. +If not provided, the SNI will be inferred from the host. + +*** + ### CurrentReplaySessionChangeEvent > **CurrentReplaySessionChangeEvent** = `object` @@ -611,7 +646,7 @@ sendRequest(sessionId, { ##### showEntry() -> **showEntry**: (`sessionId`: [`ID`](utils.md#id), `entryId`: [`ID`](utils.md#id), `options?`: `object`) => `Promise`\<`void`\> +> **showEntry**: (`sessionId`: [`ID`](utils.md#id), `entryId`: [`ID`](utils.md#id)) => `Promise`\<`void`\> Show a specific entry in a replay session. This will open the session tab if not already open, set it as the selected session, and display the specified entry. @@ -622,8 +657,6 @@ This will open the session tab if not already open, set it as the selected sessi | ------ | ------ | ------ | | `sessionId` | [`ID`](utils.md#id) | The ID of the session containing the entry. | | `entryId` | [`ID`](utils.md#id) | The ID of the entry to show. | -| `options?` | \{ `overwriteDraft?`: `boolean`; \} | The options for showing the entry. | -| `options.overwriteDraft?` | `boolean` | Whether to overwrite the request draft. If true, the draft will be removed and the entry's raw request will be shown. If false, the draft will be kept. | ###### Returns @@ -632,9 +665,7 @@ This will open the session tab if not already open, set it as the selected sessi ###### Example ```ts -await sdk.replay.showEntry(sessionId, entryId, { - overwriteDraft: true, -}); +await sdk.replay.showEntry(sessionId, entryId); ``` *** @@ -721,7 +752,7 @@ The ID of the session associated with this tab. ### RequestSource -> **RequestSource** = \{ `connectionInfo`: [`SendRequestOptions`](#sendrequestoptions)\[`"connectionInfo"`\]; `raw`: `string`; `type`: `"Raw"`; \} \| \{ `id`: `string`; `type`: `"ID"`; \} +> **RequestSource** = \{ `connectionInfo`: [`ConnectionInfo`](#connectioninfo); `raw`: `string`; `type`: `"Raw"`; \} \| \{ `id`: `string`; `type`: `"ID"`; \} #### Remarks @@ -764,66 +795,6 @@ If true, the request will not update the UI. If false, the UI will be updated to display the session and the new request. Defaults to false. -##### connectionClose? - -> `optional` **connectionClose**: `boolean` - -Whether to force close the connection by setting Connection: close header. -Defaults to true. - -##### connectionInfo - -> **connectionInfo**: `object` - -The connection information to use for the request. - -###### host - -> **host**: `string` - -The host to use for the request. - -###### isTLS - -> **isTLS**: `boolean` - -Whether the request is TLS. - -###### port - -> **port**: `number` - -The port to use for the request. - -###### SNI? - -> `optional` **SNI**: `string` - -The SNI to use for the request. -If not provided, the SNI will be inferred from the host. - -##### overwriteDraft? - -> `optional` **overwriteDraft**: `boolean` - -Whether to overwrite the editor's draft content. -If true, draft content will be overwritten with the new request. -If false, the draft will be kept. -Defaults to true. - -##### raw - -> **raw**: `string` - -The raw request to send. - -##### updateContentLength? - -> `optional` **updateContentLength**: `boolean` - -Whether to update the content length automatically to match the body. -Defaults to true. - *** ### ReplaySlot diff --git a/src/reference/sdks/frontend/utils.md b/src/reference/sdks/frontend/utils.md index c28b555..27b36c3 100644 --- a/src/reference/sdks/frontend/utils.md +++ b/src/reference/sdks/frontend/utils.md @@ -181,6 +181,24 @@ Utility type for converting endpoint return types to promises. *** +### QueryInput + +> **QueryInput** = [`HTTPQL`](#httpql) \| [`StreamQL`](#streamql) + +A query input. + +#### Examples + +```ts +`"req.method.eq:'POST'"` +``` + +```ts +`"ws.raw.cont:'hello'"` +``` + +*** + ### Selection > **Selection**\<`TId`\> = \{ `kind`: `"Empty"`; \} \| \{ `kind`: `"Selected"`; `main`: `TId`; `secondary`: `TId`[]; \} @@ -193,3 +211,23 @@ Main represents the primary selected item, secondary represents additional selec | Type Parameter | | ------ | | `TId` | + +*** + +### StreamQL + +> **StreamQL** = `string` & `object` + +A STREAMQL expression. + +#### Type Declaration + +##### \_\_streamql? + +> `optional` **\_\_streamql**: `never` + +#### Example + +```ts +`ws.raw.cont:"hello"` +``` diff --git a/src/reference/sdks/frontend/websockets.md b/src/reference/sdks/frontend/websockets.md index 4f169fb..ccc27f8 100644 --- a/src/reference/sdks/frontend/websockets.md +++ b/src/reference/sdks/frontend/websockets.md @@ -1,5 +1,51 @@ # Websockets +### MessageViewModeOptions + +> **MessageViewModeOptions** = `object` + +Options for defining a custom message view mode. + +#### Properties + +##### label + +> **label**: `string` + +The label of the view mode. + +##### view + +> **view**: [`ComponentDefinition`](utils.md#componentdefinition) + +The component to render when the view mode is selected. + +##### when()? + +> `optional` **when**: (`message`: [`StreamWsMessageMeta`](#streamwsmessagemeta)) => `boolean` + +A function that determines if the view mode should be shown for a given message. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `message` | [`StreamWsMessageMeta`](#streamwsmessagemeta) | + +###### Returns + +`boolean` + +*** + +### StreamWsMessageMeta + +> **StreamWsMessageMeta** = [`Prettify`](utils.md#prettify)\<[`As`](utils.md#as)\<`"StreamWsMessageMeta"`\> & `object`\> + +A complete message with all metadata and raw content. + +*** + ### WebsocketPageContext > **WebsocketPageContext** = `object` @@ -11,3 +57,29 @@ Certificate page context. ##### kind > **kind**: `"Websocket"` + +*** + +### WebsocketSDK + +> **WebsocketSDK** = `object` + +Utilities to interact with websockets + +#### Properties + +##### addMessageViewMode() + +> **addMessageViewMode**: (`options`: [`MessageViewModeOptions`](#messageviewmodeoptions)) => `void` + +Add a custom message view mode. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `options` | [`MessageViewModeOptions`](#messageviewmodeoptions) | The view mode options. | + +###### Returns + +`void`