From 6297766d2ec2b1ed095089e0cc4826fbe8a03da9 Mon Sep 17 00:00:00 2001 From: Hassan Khan Date: Thu, 20 Jul 2023 02:00:05 +0100 Subject: [PATCH] docs: temporarily generate and commit reference docs --- .../reference/frontend/cubejs-client-core.mdx | 1631 +++++++++++++++++ .../frontend/cubejs-client-react.mdx | 547 ++++++ .../frontend/cubejs-client-ws-transport.mdx | 132 ++ 3 files changed, 2310 insertions(+) create mode 100644 docs/docs-new/pages/reference/frontend/cubejs-client-core.mdx create mode 100644 docs/docs-new/pages/reference/frontend/cubejs-client-react.mdx create mode 100644 docs/docs-new/pages/reference/frontend/cubejs-client-ws-transport.mdx diff --git a/docs/docs-new/pages/reference/frontend/cubejs-client-core.mdx b/docs/docs-new/pages/reference/frontend/cubejs-client-core.mdx new file mode 100644 index 0000000000000..109631cad6b14 --- /dev/null +++ b/docs/docs-new/pages/reference/frontend/cubejs-client-core.mdx @@ -0,0 +1,1631 @@ +# @cubejs-client/core + +Vanilla JavaScript Cube.js client. + +## cubejs + +```typescript +cubejs(apiToken: string | () => Promise, options: CubeJSApiOptions): CubejsApi +``` + +Creates an instance of the `CubejsApi`. The API entry point. + +```js +import cubejs from '@cubejs-client/core'; +const cubejsApi = cubejs( + 'CUBEJS-API-TOKEN', + { apiUrl: 'http://localhost:4000/cubejs-api/v1' } +); +``` + +You can also pass an async function or a promise that will resolve to the API token + +```js +import cubejs from '@cubejs-client/core'; +const cubejsApi = cubejs( + async () => await Auth.getJwtToken(), + { apiUrl: 'http://localhost:4000/cubejs-api/v1' } +); +``` + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| apiToken | string | () => Promise<string> | [API token](security) is used to authorize requests and determine SQL database you're accessing. In the development mode, Cube.js Backend will print the API token to the console on startup. In case of async function `authorization` is updated for `options.transport` on each request. | +| options | CubeJSApiOptions | - | + +```typescript +cubejs(options: CubeJSApiOptions): CubejsApi +``` + +## areQueriesEqual + +```typescript +areQueriesEqual(query1: DeeplyReadonly | null, query2: DeeplyReadonly | null): boolean +``` + +## defaultHeuristics + +```typescript +defaultHeuristics(newState: TDefaultHeuristicsState, oldQuery: Query, options: TDefaultHeuristicsOptions): TDefaultHeuristicsResponse +``` + +## defaultOrder + +```typescript +defaultOrder(query: DeeplyReadonly): object +``` + +## movePivotItem + +```typescript +movePivotItem(pivotConfig: PivotConfig, sourceIndex: number, destinationIndex: number, sourceAxis: TSourceAxis, destinationAxis: TSourceAxis): PivotConfig +``` + +## validateQuery + +```typescript +validateQuery(query: DeeplyReadonly | null | undefined): Query +``` + +## CubejsApi + +Main class for accessing Cube.js API + +### dryRun + +```typescript +dryRun(query: DeeplyReadonly, options?: LoadMethodOptions): Promise +``` + +```typescript +dryRun(query: DeeplyReadonly, options: LoadMethodOptions, callback?: LoadMethodCallback): UnsubscribeObj +``` + +Get query related meta without query execution + +### load + +```typescript +load(query: QueryType, options?: LoadMethodOptions): Promise>> +``` + +**Type parameters:** + +- **QueryType**: `DeeplyReadonly` + +```typescript +load(query: QueryType, options?: LoadMethodOptions, callback?: LoadMethodCallback>>): UnsubscribeObj +``` + +Fetch data for the passed `query`. + +```js +import cubejs from '@cubejs-client/core'; +import Chart from 'chart.js'; +import chartjsConfig from './toChartjsData'; + +const cubejsApi = cubejs('CUBEJS_TOKEN'); + +const resultSet = await cubejsApi.load({ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +}); + +const context = document.getElementById('myChart'); +new Chart(context, chartjsConfig(resultSet)); +``` + +**Type parameters:** + +- **QueryType**: `DeeplyReadonly` + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| query | QueryType | [Query object](query-format) | +| options? | LoadMethodOptions | - | +| callback? | LoadMethodCallback<ResultSet<QueryRecordType<QueryType>>> | - | + +```typescript +load(query: QueryType, options?: LoadMethodOptions, callback?: LoadMethodCallback, responseFormat?: string): Promise>> +``` + +**Type parameters:** + +- **QueryType**: `DeeplyReadonly` + +### meta + +```typescript +meta(options?: LoadMethodOptions): Promise +``` + +```typescript +meta(options?: LoadMethodOptions, callback?: LoadMethodCallback): UnsubscribeObj +``` + +Get meta description of cubes available for querying. + +### sql + +```typescript +sql(query: DeeplyReadonly, options?: LoadMethodOptions): Promise +``` + +```typescript +sql(query: DeeplyReadonly, options?: LoadMethodOptions, callback?: LoadMethodCallback): UnsubscribeObj +``` + +Get generated SQL string for the given `query`. + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| query | DeeplyReadonly<Query | Query[]> | [Query object](query-format) | +| options? | LoadMethodOptions | - | +| callback? | LoadMethodCallback<SqlQuery> | - | + +### subscribe + +```typescript +subscribe(query: QueryType, options: LoadMethodOptions | null, callback: LoadMethodCallback>>): UnsubscribeObj +``` + +Allows you to fetch data and receive updates over time. See [Real-Time Data Fetch](real-time-data-fetch) + +```js +// Subscribe to a query's updates +const subscription = await cubejsApi.subscribe( + { + measures: ['Logs.count'], + timeDimensions: [ + { + dimension: 'Logs.time', + granularity: 'hour', + dateRange: 'last 1440 minutes', + }, + ], + }, + options, + (error, resultSet) => { + if (!error) { + // handle the update + } + } +); + +// Unsubscribe from a query's updates +subscription.unsubscribe(); +``` + +**Type parameters:** + +- **QueryType**: `DeeplyReadonly` + +## HttpTransport + +Default transport implementation. + +### constructor + +```typescript +new HttpTransport(options: TransportOptions): HttpTransport +``` + +### request + +```typescript +request(method: string, params: any): ITransportResponse +``` + +## Meta + +Contains information about available cubes and it's members. + +### constructor + +```typescript +new Meta(metaResponse: MetaResponse): Meta +``` + +### cubes + +``` + cubes: Cube[] +``` + +An array of all available cubes with their members + +### cubesMap + +``` + cubesMap: CubesMap +``` + +A map of all cubes where the key is a cube name + +### meta + +``` + meta: MetaResponse +``` + +Raw meta response + +### defaultTimeDimensionNameFor + +```typescript +defaultTimeDimensionNameFor(memberName: string): string +``` + +### filterOperatorsForMember + +```typescript +filterOperatorsForMember(memberName: string, memberType: MemberType | MemberType[]): FilterOperator[] +``` + +### membersForQuery + +```typescript +membersForQuery(query: DeeplyReadonly | null, memberType: MemberType): TCubeMeasure[] | TCubeDimension[] | TCubeMember[] +``` + +Get all members of a specific type for a given query. +If empty query is provided no filtering is done based on query context and all available members are retrieved. + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| query | DeeplyReadonly<Query> | null | context query to provide filtering of members available to add to this query | +| memberType | MemberType | - | + +### membersGroupedByCube + +```typescript +membersGroupedByCube(): any +``` + +### resolveMember + +```typescript +resolveMember(memberName: string, memberType: T | T[]): object | TCubeMemberByType +``` + +Get meta information for a cube member +Member meta information contains: +```javascript +{ + name, + title, + shortTitle, + type, + description, + format +} +``` + +**Type parameters:** + +- **T**: `MemberType` + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| memberName | string | Fully qualified member name in a form `Cube.memberName` | +| memberType | T | T[] | - | + +## ProgressResult + +### stage + +```typescript +stage(): string +``` + +### timeElapsed + +```typescript +timeElapsed(): string +``` + +## ResultSet + +Provides a convenient interface for data manipulation. + +### annotation + +```typescript +annotation(): QueryAnnotations +``` + +### categories + +```typescript +categories(pivotConfig?: PivotConfig): ChartPivotRow[] +``` + +### chartPivot + +```typescript +chartPivot(pivotConfig?: PivotConfig): ChartPivotRow[] +``` + +Returns normalized query result data in the following format. + +You can find the examples of using the `pivotConfig` [here](#types-pivot-config) +```js +// For the query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +} + +// ResultSet.chartPivot() will return +[ + { "x":"2015-01-01T00:00:00", "Stories.count": 27120, "xValues": ["2015-01-01T00:00:00"] }, + { "x":"2015-02-01T00:00:00", "Stories.count": 25861, "xValues": ["2015-02-01T00:00:00"] }, + { "x":"2015-03-01T00:00:00", "Stories.count": 29661, "xValues": ["2015-03-01T00:00:00"] }, + //... +] + +``` +When using `chartPivot()` or `seriesNames()`, you can pass `aliasSeries` in the [pivotConfig](#types-pivot-config) +to give each series a unique prefix. This is useful for `blending queries` which use the same measure multiple times. + +```js +// For the queries +{ + measures: ['Stories.count'], + timeDimensions: [ + { + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month', + }, + ], +}, +{ + measures: ['Stories.count'], + timeDimensions: [ + { + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month', + }, + ], + filters: [ + { + member: 'Stores.read', + operator: 'equals', + value: ['true'], + }, + ], +}, + +// ResultSet.chartPivot({ aliasSeries: ['one', 'two'] }) will return +[ + { + x: '2015-01-01T00:00:00', + 'one,Stories.count': 27120, + 'two,Stories.count': 8933, + xValues: ['2015-01-01T00:00:00'], + }, + { + x: '2015-02-01T00:00:00', + 'one,Stories.count': 25861, + 'two,Stories.count': 8344, + xValues: ['2015-02-01T00:00:00'], + }, + { + x: '2015-03-01T00:00:00', + 'one,Stories.count': 29661, + 'two,Stories.count': 9023, + xValues: ['2015-03-01T00:00:00'], + }, + //... +]; +``` + +### decompose + +```typescript +decompose(): ResultSet[] +``` + +Can be used when you need access to the methods that can't be used with some query types (eg `compareDateRangeQuery` or `blendingQuery`) +```js +resultSet.decompose().forEach((currentResultSet) => { + console.log(currentResultSet.rawData()); +}); +``` + +### drillDown + +```typescript +drillDown(drillDownLocator: DrillDownLocator, pivotConfig?: PivotConfig): Query | null +``` + +Returns a measure drill down query. + +Provided you have a measure with the defined `drillMemebers` on the `Orders` cube +```js +measures: { + count: { + type: `count`, + drillMembers: [Orders.status, Users.city, count], + }, + // ... +} +``` + +Then you can use the `drillDown` method to see the rows that contribute to that metric +```js +resultSet.drillDown( + { + xValues, + yValues, + }, + // you should pass the `pivotConfig` if you have used it for axes manipulation + pivotConfig +) +``` + +the result will be a query with the required filters applied and the dimensions/measures filled out +```js +{ + measures: ['Orders.count'], + dimensions: ['Orders.status', 'Users.city'], + filters: [ + // dimension and measure filters + ], + timeDimensions: [ + //... + ] +} +``` + +In case when you want to add `order` or `limit` to the query, you can simply spread it + +```js +// An example for React +const drillDownResponse = useCubeQuery( + { + ...drillDownQuery, + limit: 30, + order: { + 'Orders.ts': 'desc' + } + }, + { + skip: !drillDownQuery + } + ); +``` + +### pivot + +```typescript +pivot(pivotConfig?: PivotConfig): PivotRow[] +``` + +Base method for pivoting [ResultSet](#result-set) data. +Most of the times shouldn't be used directly and [chartPivot](#result-set-chart-pivot) +or [tablePivot](#table-pivot) should be used instead. + +You can find the examples of using the `pivotConfig` [here](#types-pivot-config) +```js +// For query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-03-31'], + granularity: 'month' + }] +} + +// ResultSet.pivot({ x: ['Stories.time'], y: ['measures'] }) will return +[ + { + xValues: ["2015-01-01T00:00:00"], + yValuesArray: [ + [['Stories.count'], 27120] + ] + }, + { + xValues: ["2015-02-01T00:00:00"], + yValuesArray: [ + [['Stories.count'], 25861] + ] + }, + { + xValues: ["2015-03-01T00:00:00"], + yValuesArray: [ + [['Stories.count'], 29661] + ] + } +] +``` + +### query + +```typescript +query(): Query +``` + +### rawData + +```typescript +rawData(): T[] +``` + +### serialize + +```typescript +serialize(): SerializedResult +``` + +Can be used to stash the `ResultSet` in a storage and restored later with [deserialize](#result-set-deserialize) + +### series + +```typescript +series(pivotConfig?: PivotConfig): Series[] +``` + +Returns an array of series with key, title and series data. +```js +// For the query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +} + +// ResultSet.series() will return +[ + { + key: 'Stories.count', + title: 'Stories Count', + shortTitle: 'Count', + series: [ + { x: '2015-01-01T00:00:00', value: 27120 }, + { x: '2015-02-01T00:00:00', value: 25861 }, + { x: '2015-03-01T00:00:00', value: 29661 }, + //... + ], + }, +] +``` + +**Type parameters:** + +- **SeriesItem** + +### seriesNames + +```typescript +seriesNames(pivotConfig?: PivotConfig): SeriesNamesColumn[] +``` + +Returns an array of series objects, containing `key` and `title` parameters. +```js +// For query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +} + +// ResultSet.seriesNames() will return +[ + { + key: 'Stories.count', + title: 'Stories Count', + shortTitle: 'Count', + yValues: ['Stories.count'], + }, +] +``` + +### tableColumns + +```typescript +tableColumns(pivotConfig?: PivotConfig): TableColumn[] +``` + +Returns an array of column definitions for `tablePivot`. + +For example: +```js +// For the query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +} + +// ResultSet.tableColumns() will return +[ + { + key: 'Stories.time', + dataIndex: 'Stories.time', + title: 'Stories Time', + shortTitle: 'Time', + type: 'time', + format: undefined, + }, + { + key: 'Stories.count', + dataIndex: 'Stories.count', + title: 'Stories Count', + shortTitle: 'Count', + type: 'count', + format: undefined, + }, + //... +] +``` + +In case we want to pivot the table axes +```js +// Let's take this query as an example +{ + measures: ['Orders.count'], + dimensions: ['Users.country', 'Users.gender'] +} + +// and put the dimensions on `y` axis +resultSet.tableColumns({ + x: [], + y: ['Users.country', 'Users.gender', 'measures'] +}) +``` + +then `tableColumns` will group the table head and return +```js +{ + key: 'Germany', + type: 'string', + title: 'Users Country Germany', + shortTitle: 'Germany', + meta: undefined, + format: undefined, + children: [ + { + key: 'male', + type: 'string', + title: 'Users Gender male', + shortTitle: 'male', + meta: undefined, + format: undefined, + children: [ + { + // ... + dataIndex: 'Germany.male.Orders.count', + shortTitle: 'Count', + }, + ], + }, + { + // ... + shortTitle: 'female', + children: [ + { + // ... + dataIndex: 'Germany.female.Orders.count', + shortTitle: 'Count', + }, + ], + }, + ], +}, +// ... +``` + +### tablePivot + +```typescript +tablePivot(pivotConfig?: PivotConfig): Array +``` + +Returns normalized query result data prepared for visualization in the table format. + +You can find the examples of using the `pivotConfig` [here](#types-pivot-config) + +For example: +```js +// For the query +{ + measures: ['Stories.count'], + timeDimensions: [{ + dimension: 'Stories.time', + dateRange: ['2015-01-01', '2015-12-31'], + granularity: 'month' + }] +} + +// ResultSet.tablePivot() will return +[ + { "Stories.time": "2015-01-01T00:00:00", "Stories.count": 27120 }, + { "Stories.time": "2015-02-01T00:00:00", "Stories.count": 25861 }, + { "Stories.time": "2015-03-01T00:00:00", "Stories.count": 29661 }, + //... +] +``` + +### tableRow + +```typescript +tableRow(): ChartPivotRow +``` + +### totalRow + +```typescript +totalRow(pivotConfig?: PivotConfig): ChartPivotRow +``` + +### deserialize + +```typescript +static deserialize(data: Object, options?: Object): ResultSet +``` + +```js +import { ResultSet } from '@cubejs-client/core'; + +const resultSet = await cubejsApi.load(query); +// You can store the result somewhere +const tmp = resultSet.serialize(); + +// and restore it later +const resultSet = ResultSet.deserialize(tmp); +``` + +**Type parameters:** + +- **TData** + +**Parameters:** + +| Name | Type | Description | +| ------ | ------ | ------ | +| data | Object | the result of [serialize](#result-set-serialize) | +| options? | Object | - | + +### getNormalizedPivotConfig + +```typescript +static getNormalizedPivotConfig(query: PivotQuery, pivotConfig?: Partial): PivotConfig +``` + +## SqlQuery + +### rawQuery + +```typescript +rawQuery(): SqlData +``` + +### sql + +```typescript +sql(): string +``` + +## BinaryFilter + +### dimension + +``` + dimension? : string +``` + +**`deprecated`** Use `member` instead. + +### member + +``` + member? : string +``` + +### operator + +``` + operator: BinaryOperator +``` + +### values + +``` + values: string[] +``` + +## ITransport + +### request + +```typescript +request(method: string, params: Record): ITransportResponse +``` + +## ITransportResponse + +### subscribe + +``` + subscribe: function +``` + +### unsubscribe + +``` + unsubscribe? : function +``` + +## Query + +### dimensions + +``` + dimensions? : string[] +``` + +### filters + +``` + filters? : Filter[] +``` + +### limit + +``` + limit? : null | number +``` + +### measures + +``` + measures? : string[] +``` + +### offset + +``` + offset? : number +``` + +### order + +``` + order? : TQueryOrderObject | TQueryOrderArray +``` + +### renewQuery + +``` + renewQuery? : boolean +``` + +### responseFormat + +``` + responseFormat? : "compact" | "default" +``` + +### segments + +``` + segments? : string[] +``` + +### timeDimensions + +``` + timeDimensions? : TimeDimension[] +``` + +### timezone + +``` + timezone? : string +``` + +### total + +``` + total? : boolean +``` + +### ungrouped + +``` + ungrouped? : boolean +``` + +## TFlatFilter + +### dimension + +``` + dimension? : string +``` + +**`deprecated`** Use `member` instead. + +### member + +``` + member? : string +``` + +### operator + +``` + operator: BinaryOperator +``` + +### values + +``` + values: string[] +``` + +## TimeDimensionBase + +### dimension + +``` + dimension: string +``` + +### granularity + +``` + granularity? : TimeDimensionGranularity +``` + +## UnaryFilter + +### dimension + +``` + dimension? : string +``` + +**`deprecated`** Use `member` instead. + +### member + +``` + member? : string +``` + +### operator + +``` + operator: UnaryOperator +``` + +### values + +``` + values? : never +``` + +## UnsubscribeObj + +### unsubscribe + +```typescript +unsubscribe(): Promise +``` + +Allows to stop requests in-flight in long polling or web socket subscribe loops. +It doesn't cancel any submitted requests to the underlying databases. + +## Types + +### Annotation + +| Name | Type | +| ------ | ------ | +| format? | "currency" | "percent" | "number" | +| shortTitle | string | +| title | string | +| type | string | + +### BaseCubeMember + +| Name | Type | +| ------ | ------ | +| isVisible? | boolean | +| meta? | any | +| name | string | +| shortTitle | string | +| title | string | +| type | TCubeMemberType | + +### BinaryOperator + +``` + BinaryOperator: "equals" | "notEquals" | "contains" | "notContains" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith" | "gt" | "gte" | "lt" | "lte" | "inDateRange" | "notInDateRange" | "beforeDate" | "afterDate" +``` + +### ChartPivotRow + +| Name | Type | +| ------ | ------ | +| x | string | +| xValues | string[] | + +### ChartType + +``` + ChartType: "line" | "bar" | "table" | "area" | "number" | "pie" +``` + +### Column + +| Name | Type | +| ------ | ------ | +| key | string | +| series | [] | +| title | string | + +### Cube + +| Name | Type | +| ------ | ------ | +| dimensions | TCubeDimension[] | +| measures | TCubeMeasure[] | +| name | string | +| segments | TCubeSegment[] | +| title | string | + +### CubeJSApiOptions + +| Name | Type | Description | +| ------ | ------ | ------ | +| apiUrl | string | URL of your Cube.js Backend. By default, in the development environment it is `http://localhost:4000/cubejs-api/v1` | +| credentials? | "omit" | "same-origin" | "include" | - | +| headers? | Record<string, string> | - | +| parseDateMeasures? | boolean | - | +| pollInterval? | number | - | +| resType? | "default" | "compact" | - | +| transport? | ITransport<any> | Transport implementation to use. [HttpTransport](#http-transport) will be used by default. | + +### CubeMap + +| Name | Type | +| ------ | ------ | +| dimensions | Record<string, TCubeDimension> | +| measures | Record<string, TCubeMeasure> | +| segments | Record<string, TCubeSegment> | + +### CubeMember + +``` + CubeMember: TCubeMeasure | TCubeDimension | TCubeSegment +``` + +### CubesMap + +``` + CubesMap: Record +``` + +### DateRange + +``` + DateRange: string | [string, string] +``` + +### DeeplyReadonly + +### DrillDownLocator + +| Name | Type | +| ------ | ------ | +| xValues | string[] | +| yValues? | string[] | + +### DryRunResponse + +| Name | Type | +| ------ | ------ | +| normalizedQueries | Query[] | +| pivotQuery | PivotQuery | +| queryOrder | Array<object> | +| queryType | QueryType | +| transformedQueries | TransformedQuery[] | + +### ExtractMembers + +``` + ExtractMembers: T extends object ? Names : never | T extends object ? Names : never | T extends object ? ExtractTimeMembers : never +``` + +### ExtractTimeMember + +``` + ExtractTimeMember: T extends object ? Dimension | `${Dimension & string}.${Granularity & string}` : never +``` + +### ExtractTimeMembers + +``` + ExtractTimeMembers: T extends readonly [infer First] ? ExtractTimeMember | ExtractTimeMembers : never +``` + +### Filter + +``` + Filter: BinaryFilter | UnaryFilter | LogicalOrFilter | LogicalAndFilter +``` + +### FilterOperator + +| Name | Type | +| ------ | ------ | +| name | string | +| title | string | + +### LeafMeasure + +| Name | Type | +| ------ | ------ | +| additive | boolean | +| measure | string | +| type | "count" | "countDistinct" | "sum" | "min" | "max" | "number" | "countDistinctApprox" | + +### LoadMethodCallback + +``` + LoadMethodCallback: function +``` + +### LoadMethodOptions + +| Name | Type | Description | +| ------ | ------ | ------ | +| progressCallback? | | - | +| cubejsApi? | CubejsApi | A Cube.js API instance. If not provided will be taken from `CubeProvider` | +| mutexKey? | string | Key to store the current request's MUTEX inside the `mutexObj`. MUTEX object is used to reject orphaned queries results when new queries are sent. For example: if two queries are sent with the same `mutexKey` only the last one will return results. | +| mutexObj? | Object | Object to store MUTEX | +| subscribe? | boolean | Pass `true` to use continuous fetch behavior. | + +### LoadResponse + +| Name | Type | +| ------ | ------ | +| pivotQuery | PivotQuery | +| queryType | QueryType | +| results | LoadResponseResult<T>[] | + +### LoadResponseResult + +| Name | Type | +| ------ | ------ | +| annotation | QueryAnnotations | +| data | T[] | +| dbType | string | +| extDbType | string | +| external | boolean | null | +| lastRefreshTime | string | +| query | Query | +| requestId? | string | +| total? | number | +| transformedQuery? | TransformedQuery | +| usedPreAggregations? | Record<string, UsedPreAggregation> | + +### LogicalAndFilter + +| Name | Type | +| ------ | ------ | +| and | Filter[] | + +### LogicalOrFilter + +| Name | Type | +| ------ | ------ | +| or | Filter[] | + +### MemberType + +``` + MemberType: "measures" | "dimensions" | "segments" +``` + +### MetaResponse + +| Name | Type | +| ------ | ------ | +| cubes | Cube[] | + +### PivotConfig + +Configuration object that contains information about pivot axes and other options. + +Let's apply `pivotConfig` and see how it affects the axes +```js +// Example query +{ + measures: ['Orders.count'], + dimensions: ['Users.country', 'Users.gender'] +} +``` +If we put the `Users.gender` dimension on **y** axis +```js +resultSet.tablePivot({ + x: ['Users.country'], + y: ['Users.gender', 'measures'] +}) +``` + +The resulting table will look the following way + +| Users Country | male, Orders.count | female, Orders.count | +| ------------- | ------------------ | -------------------- | +| Australia | 3 | 27 | +| Germany | 10 | 12 | +| US | 5 | 7 | + +Now let's put the `Users.country` dimension on **y** axis instead +```js +resultSet.tablePivot({ + x: ['Users.gender'], + y: ['Users.country', 'measures'], +}); +``` + +in this case the `Users.country` values will be laid out on **y** or **columns** axis + +| Users Gender | Australia, Orders.count | Germany, Orders.count | US, Orders.count | +| ------------ | ----------------------- | --------------------- | ---------------- | +| male | 3 | 10 | 5 | +| female | 27 | 12 | 7 | + +It's also possible to put the `measures` on **x** axis. But in either case it should always be the last item of the array. +```js +resultSet.tablePivot({ + x: ['Users.gender', 'measures'], + y: ['Users.country'], +}); +``` + +| Users Gender | measures | Australia | Germany | US | +| ------------ | ------------ | --------- | ------- | --- | +| male | Orders.count | 3 | 10 | 5 | +| female | Orders.count | 27 | 12 | 7 | + +| Name | Type | Description | +| ------ | ------ | ------ | +| aliasSeries? | string[] | Give each series a prefix alias. Should have one entry for each query:measure. See [chartPivot](#result-set-chart-pivot) | +| fillMissingDates? | boolean | null | If `true` missing dates on the time dimensions will be filled with `0` for all measures.Note: the `fillMissingDates` option set to `true` will override any **order** applied to the query | +| x? | string[] | Dimensions to put on **x** or **rows** axis. | +| y? | string[] | Dimensions to put on **y** or **columns** axis. | + +### PivotQuery + +``` + PivotQuery: Query & object +``` + +### PivotRow + +| Name | Type | +| ------ | ------ | +| xValues | Array<string | number> | +| yValuesArray | Array<[string[], number]> | + +### PreAggregationType + +``` + PreAggregationType: "rollup" | "rollupJoin" | "rollupLambda" | "originalSql" +``` + +### ProgressResponse + +| Name | Type | +| ------ | ------ | +| stage | string | +| timeElapsed | number | + +### QueryAnnotations + +| Name | Type | +| ------ | ------ | +| dimensions | Record<string, Annotation> | +| measures | Record<string, Annotation> | +| timeDimensions | Record<string, Annotation> | + +### QueryArrayRecordType + +``` + QueryArrayRecordType: T extends readonly [infer First] ? SingleQueryRecordType | QueryArrayRecordType> : never +``` + +### QueryOrder + +``` + QueryOrder: "asc" | "desc" +``` + +### QueryRecordType + +``` + QueryRecordType: T extends DeeplyReadonly ? QueryArrayRecordType : T extends DeeplyReadonly ? SingleQueryRecordType : never +``` + +### QueryType + +``` + QueryType: "regularQuery" | "compareDateRangeQuery" | "blendingQuery" +``` + +### SerializedResult + +| Name | Type | +| ------ | ------ | +| loadResponse | LoadResponse<T> | + +### Series + +| Name | Type | +| ------ | ------ | +| key | string | +| series | T[] | +| shortTitle | string | +| title | string | + +### SeriesNamesColumn + +| Name | Type | +| ------ | ------ | +| key | string | +| shortTitle | string | +| title | string | +| yValues | string[] | + +### SingleQueryRecordType + +``` + SingleQueryRecordType: ExtractMembers extends never ? any : object +``` + +### SqlData + +| Name | Type | +| ------ | ------ | +| aliasNameToMember | Record<string, string> | +| cacheKeyQueries | SqlQueryTuple[] | +| dataSource | boolean | +| external | boolean | +| preAggregations | any[] | +| rollupMatchResults | any[] | +| sql | SqlQueryTuple | + +### SqlQueryTuple + +``` + SqlQueryTuple: [string, any[], any] +``` + +### TCubeDimension + +``` + TCubeDimension: BaseCubeMember & object +``` + +### TCubeMeasure + +``` + TCubeMeasure: BaseCubeMember & object +``` + +### TCubeMember + +| Name | Type | +| ------ | ------ | +| isVisible? | boolean | +| meta? | any | +| name | string | +| shortTitle | string | +| title | string | +| type | TCubeMemberType | + +### TCubeMemberByType + +``` + TCubeMemberByType: T extends "measures" ? TCubeMeasure : T extends "dimensions" ? TCubeDimension : T extends "segments" ? TCubeSegment : never +``` + +### TCubeMemberType + +``` + TCubeMemberType: "time" | "number" | "string" | "boolean" +``` + +### TCubeSegment + +``` + TCubeSegment: Omit +``` + +### TDefaultHeuristicsOptions + +| Name | Type | +| ------ | ------ | +| meta | Meta | +| sessionGranularity? | TimeDimensionGranularity | + +### TDefaultHeuristicsResponse + +| Name | Type | +| ------ | ------ | +| chartType? | ChartType | +| pivotConfig | PivotConfig | null | +| query | Query | +| shouldApplyHeuristicOrder | boolean | + +### TDefaultHeuristicsState + +| Name | Type | +| ------ | ------ | +| chartType? | ChartType | +| query | Query | + +### TDryRunResponse + +**`deprecated`** use DryRunResponse + +| Name | Type | +| ------ | ------ | +| normalizedQueries | Query[] | +| pivotQuery | PivotQuery | +| queryOrder | Array<object> | +| queryType | QueryType | +| transformedQueries | TransformedQuery[] | + +### TGranularityMap + +| Name | Type | +| ------ | ------ | +| name | TimeDimensionGranularity | undefined | +| title | string | + +### TOrderMember + +| Name | Type | +| ------ | ------ | +| id | string | +| order | QueryOrder | "none" | +| title | string | + +### TQueryOrderArray + +``` + TQueryOrderArray: Array<[string, QueryOrder]> +``` + +### TQueryOrderObject + +### TableColumn + +| Name | Type | +| ------ | ------ | +| children? | TableColumn[] | +| dataIndex | string | +| format? | any | +| key | string | +| meta | any | +| shortTitle | string | +| title | string | +| type | string | number | + +### TimeDimension + +``` + TimeDimension: TimeDimensionComparison | TimeDimensionRanged +``` + +### TimeDimensionComparison + +``` + TimeDimensionComparison: TimeDimensionBase & TimeDimensionComparisonFields +``` + +### TimeDimensionComparisonFields + +| Name | Type | +| ------ | ------ | +| compareDateRange | Array<DateRange> | +| dateRange? | never | + +### TimeDimensionGranularity + +``` + TimeDimensionGranularity: "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" +``` + +### TimeDimensionRanged + +``` + TimeDimensionRanged: TimeDimensionBase & TimeDimensionRangedFields +``` + +### TimeDimensionRangedFields + +| Name | Type | +| ------ | ------ | +| dateRange? | DateRange | + +### TransformedQuery + +| Name | Type | +| ------ | ------ | +| allFiltersWithinSelectedDimensions | boolean | +| granularityHierarchies | Record<string, string[]> | +| hasMultipliedMeasures | boolean | +| hasNoTimeDimensionsWithoutGranularity | boolean | +| isAdditive | boolean | +| leafMeasureAdditive | boolean | +| leafMeasures | string[] | +| measureToLeafMeasures? | Record<string, LeafMeasure[]> | +| measures | string[] | +| sortedDimensions | string[] | +| sortedTimeDimensions | [[string, string]] | + +### TransportOptions + +| Name | Type | Description | +| ------ | ------ | ------ | +| apiUrl | string | path to `/cubejs-api/v1` | +| authorization | string | [jwt auth token](security) | +| credentials? | "omit" | "same-origin" | "include" | - | +| headers? | Record<string, string> | custom headers | +| method? | "GET" | "PUT" | "POST" | "PATCH" | - | + +### UnaryOperator + +``` + UnaryOperator: "set" | "notSet" +``` + +### UsedPreAggregation + +| Name | Type | +| ------ | ------ | +| targetTableName | string | +| type | PreAggregationType | + +## GRANULARITIES + +``` + GRANULARITIES: TGranularityMap[] +``` diff --git a/docs/docs-new/pages/reference/frontend/cubejs-client-react.mdx b/docs/docs-new/pages/reference/frontend/cubejs-client-react.mdx new file mode 100644 index 0000000000000..dc88eceb177a0 --- /dev/null +++ b/docs/docs-new/pages/reference/frontend/cubejs-client-react.mdx @@ -0,0 +1,547 @@ +# @cubejs-client/react + +`@cubejs-client/react` provides React Components for easy Cube.js integration in a React app. + +## useCubeQuery + +```typescript +useCubeQuery(query: TQuery, options?: UseCubeQueryOptions): UseCubeQueryResult : TData> +``` + +A React hook for executing Cube.js queries +```js +import React from 'react'; +import { Table } from 'antd'; +import { useCubeQuery } from '@cubejs-client/react'; + +export default function App() { + const { resultSet, isLoading, error, progress } = useCubeQuery({ + measures: ['Orders.count'], + dimensions: ['Orders.createdAt.month'], + }); + + if (isLoading) { + return
{progress?.stage || 'Loading...'}
; + } + + if (error) { + return
{error.toString()}
; + } + + if (!resultSet) { + return null; + } + + const dataSource = resultSet.tablePivot(); + const columns = resultSet.tableColumns(); + + return ; +} + +``` + +**Type parameters:** + +- **TData** + +- **TQuery**: `DeeplyReadonly` + +### UseCubeQueryOptions + +| Name | Type | Description | +| ------ | ------ | ------ | +| cubejsApi? | CubejsApi | A `CubejsApi` instance to use. Taken from the context if the param is not passed | +| resetResultSetOnChange? | boolean | When `true` the resultSet will be reset to `null` first | +| skip? | boolean | Query execution will be skipped when `skip` is set to `true`. You can use this flag to avoid sending incomplete queries. | +| subscribe? | boolean | Use continuous fetch behavior. See [Real-Time Data Fetch](real-time-data-fetch) | + +### UseCubeQueryResult + +| Name | Type | +| ------ | ------ | +| error | Error | null | +| isLoading | boolean | +| progress | ProgressResponse | +| refetch | () => Promise<void> | +| resultSet | ResultSet<TData> | null | + +## isQueryPresent + +```typescript +isQueryPresent(query: Query | Query[]): boolean +``` + +Checks whether the query is ready + +## useCubeMeta + +```typescript +useCubeMeta(options?: Omit): CubeFetchResult +``` + +## QueryBuilder + +``` + QueryBuilder extends React.Component ‹QueryBuilderProps, QueryBuilderState›: +``` + +`` is used to build interactive analytics query builders. It abstracts state management and API calls to Cube.js Backend. It uses render prop technique and doesn’t render anything itself, but calls the render function instead. + +**Example** + +[Open in CodeSandbox](https://codesandbox.io/s/z6r7qj8wm) +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import { Layout, Divider, Empty, Select } from 'antd'; +import { QueryBuilder } from '@cubejs-client/react'; +import cubejs from '@cubejs-client/core'; +import 'antd/dist/antd.css'; + +import ChartRenderer from './ChartRenderer'; + +const cubejsApi = cubejs('YOUR-CUBEJS-API-TOKEN', { + apiUrl: 'http://localhost:4000/cubejs-api/v1', +}); + +const App = () => ( + ( + + + + {measures.length > 0 ? ( + + ) : ( + + )} + + )} + /> +); + +const rootElement = document.getElementById("root"); +ReactDOM.render(, rootElement); +``` + +### QueryBuilderProps + +| Name | Type | Description | +| ------ | ------ | ------ | +| cubejsApi? | CubejsApi | `CubejsApi` instance to use | +| defaultChartType? | ChartType | - | +| defaultQuery? | Query | Default query (used when initialVizState is not set or does not contain query) | +| disableHeuristics? | boolean | Defaults to `false`. This means that the default heuristics will be applied. For example: when the query is empty and you select a measure that has a default time dimension it will be pushed to the query. | +| initialVizState? | VizState | State for the QueryBuilder to start with. Pass in the value previously saved from onVizStateChanged to restore a session. | +| onVizStateChanged? | (vizState: VizState) => void | Called by the `QueryBuilder` when the viz state has changed. Use it to save state outside of the `QueryBuilder` component. | +| render | (renderProps: QueryBuilderRenderProps) => React.ReactNode | - | +| stateChangeHeuristics? | (state: QueryBuilderState, newState: QueryBuilderState) => QueryBuilderState | A function that accepts the `newState` just before it's applied. You can use it to override the **defaultHeuristics** or to tweak the query or the vizState in any way. | +| wrapWithQueryRenderer? | boolean | - | + +### QueryBuilderRenderProps + +| Name | Type | Description | +| ------ | ------ | ------ | +| availableDimensions | TCubeDimension[] | An array of available dimensions to select. They are loaded via the API from Cube.js Backend. | +| availableFilterMembers | Array<AvailableCube<TCubeMeasure> | AvailableCube<TCubeDimension>> | - | +| availableMeasures | TCubeMeasure[] | An array of available measures to select. They are loaded via the API from Cube.js Backend. | +| availableMembers | AvailableMembers | - | +| availableSegments | TCubeSegment[] | An array of available segments to select. They are loaded via the API from Cube.js Backend. | +| availableTimeDimensions | TCubeDimension[] | An array of available time dimensions to select. They are loaded via the API from Cube.js Backend. | +| chartType? | ChartType | Selected chart type | +| dimensions | TCubeDimension & object[] | - | +| dryRunResponse? | DryRunResponse | - | +| error? | Error | null | - | +| filters | FilterWithExtraFields & object[] | - | +| isFetchingMeta | boolean | - | +| isQueryPresent | boolean | Indicates whether the query is ready to be displayed or not | +| loadingState? | TLoadingState | - | +| measures | TCubeMeasure & object[] | - | +| meta | Meta | undefined | - | +| metaError? | Error | null | - | +| metaErrorStack? | string | null | - | +| missingMembers | string[] | - | +| orderMembers | TOrderMember[] | All possible order members for the query | +| pivotConfig? | PivotConfig | See [Pivot Config](@cubejs-client-core#types-pivot-config) | +| query | Query | Used to set the initial query for this component. Note that adding this prop turns this into an uncontrolled component and will only be able to execute `dryRun` queries. To use this component as a controlled component, use `setQuery` instead. | +| refresh | () => void | - | +| resultSet? | ResultSet | null | - | +| richMetaError? | Error | null | - | +| segments | TCubeSegment & object[] | - | +| timeDimensions | TimeDimensionWithExtraFields & object[] | - | +| updateChartType | (chartType: ChartType) => void | Used for chart type update | +| updateDimensions | DimensionUpdater | - | +| updateFilters | FilterUpdater | - | +| updateMeasures | MeasureUpdater | - | +| updateOrder | OrderUpdater | Used for query order update | +| updatePivotConfig | PivotConfigUpdater | Helper method for `pivotConfig` updates | +| updateQuery | (query: Query) => void | Used for partial of full query update | +| updateSegments | SegmentUpdater | - | +| updateTimeDimensions | TimeDimensionUpdater | - | +| validatedQuery | Query | - | + +### QueryBuilderState + +``` + QueryBuilderState: VizState & object +``` + +## QueryRenderer + +``` + QueryRenderer extends React.Component ‹QueryRendererProps›: +``` + +`` a react component that accepts a query, fetches the given query, and uses the render prop to render the resulting data + +### QueryRendererProps + +| Name | Type | Description | +| ------ | ------ | ------ | +| cubejsApi? | CubejsApi | `CubejsApi` instance to use | +| loadSql? | "only" | boolean | Indicates whether the generated by `Cube.js` SQL Code should be requested. See [rest-api#sql](rest-api#api-reference-v-1-sql). When set to `only` then only the request to [/v1/sql](rest-api#api-reference-v-1-sql) will be performed. When set to `true` the sql request will be performed along with the query request. Will not be performed if set to `false` | +| queries? | object | - | +| query | Query | Query[] | Analytic query. [Learn more about it's format](query-format) | +| render | (renderProps: QueryRendererRenderProps) => void | Output of this function will be rendered by the `QueryRenderer` | +| resetResultSetOnChange? | boolean | When `true` the **resultSet** will be reset to `null` first on every state change | +| updateOnlyOnStateChange? | boolean | - | + +### QueryRendererRenderProps + +| Name | Type | +| ------ | ------ | +| error | Error | null | +| loadingState | TLoadingState | +| resultSet | ResultSet | null | +| sqlQuery | SqlQuery | null | + +## CubeProvider + +``` + CubeProvider: React.FC +``` + +Cube.js context provider +```js +import React from 'react'; +import cubejs from '@cubejs-client/core'; +import { CubeProvider } from '@cubejs-client/react'; + +const API_URL = 'https://harsh-eel.aws-us-east-2.cubecloudapp.dev'; +const CUBEJS_TOKEN = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.* eyJpYXQiOjE1OTE3MDcxNDgsImV4cCI6MTU5NDI5OTE0OH0.* n5jGLQJ14igg6_Hri_Autx9qOIzVqp4oYxmX27V-4T4'; + +const cubejsApi = cubejs(CUBEJS_TOKEN, { + apiUrl: `${API_URL}/cubejs-api/v1`, +}); + +export default function App() { + return ( + + //... + + ) +} +``` + +## CubeContext + +``` + CubeContext: Context +``` + +In case when you need direct access to `cubejsApi` you can use `CubeContext` anywhere in your app + +```js +import React from 'react'; +import { CubeContext } from '@cubejs-client/react'; + +export default function DisplayComponent() { + const { cubejsApi } = React.useContext(CubeContext); + const [rawResults, setRawResults] = React.useState([]); + const query = { + ... + }; + + React.useEffect(() => { + cubejsApi.load(query).then((resultSet) => { + setRawResults(resultSet.rawData()); + }); + }, [query]); + + return ( + <> + {rawResults.map(row => ( + ... + ))} + + ) +} +``` + +## Types + +### AvailableCube + +| Name | Type | +| ------ | ------ | +| cubeName | string | +| cubeTitle | string | +| members | T[] | +| public | boolean | +| type | "cube" | "view" | + +### AvailableMembers + +| Name | Type | +| ------ | ------ | +| dimensions | AvailableCube<TCubeDimension>[] | +| measures | AvailableCube<TCubeMeasure>[] | +| segments | AvailableCube<TCubeSegment>[] | +| timeDimensions | AvailableCube<TCubeDimension>[] | + +### ChartType + +``` + ChartType: "line" | "bar" | "table" | "area" | "number" | "pie" +``` + +### CubeContextProps + +| Name | Type | +| ------ | ------ | +| cubejsApi | CubejsApi | + +### CubeProviderProps + +| Name | Type | +| ------ | ------ | +| children | React.ReactNode | +| cubejsApi | CubejsApi | null | + +### DimensionUpdater + +``` + DimensionUpdater: MemberUpdater +``` + +### FilterExtraFields + +| Name | Type | +| ------ | ------ | +| dimension | TCubeDimension | TCubeMeasure | +| operators | object[] | + +### FilterUpdateFields + +| Name | Type | +| ------ | ------ | +| dimension | TCubeDimension | TCubeMeasure | +| member? | string | +| operator | BinaryOperator | UnaryOperator | +| values? | string[] | + +### FilterUpdater + +``` + FilterUpdater: MemberUpdater +``` + +### FilterWithExtraFields + +``` + FilterWithExtraFields: Omit & FilterExtraFields +``` + +### GranularityOptions + +| Name | Type | +| ------ | ------ | +| granularities | object[] | + +### MeasureUpdater + +``` + MeasureUpdater: MemberUpdater +``` + +### MemberUpdater + +You can use the following methods for member manipulaltion +```js + { + return ( + // ... + + ); + }} +/> +``` + +NOTE: if you need to add or remove more than one member at a time you should use `updateQuery` prop of [QueryBuilderRenderProps](#query-builder-query-builder-render-props) +```js + { + // ... + return ( + <> + // WRONG: This code will not work properly + + + // CORRECT: Using `updateQuery` for removing all measures + + + ); + }} +/> +``` + +| Name | Type | +| ------ | ------ | +| add | (member: T) => void | +| remove | (member: object) => void | +| update | (member: object, updateWith: T) => void | + +### OrderUpdater + +| Name | Type | +| ------ | ------ | +| reorder | (sourceIndex: number, destinationIndex: number) => void | +| set | (memberId: string, order: QueryOrder | "none") => void | +| update | (order: Query["order"]) => void | + +### PivotConfigExtraUpdateFields + +| Name | Type | +| ------ | ------ | +| limit? | number | + +### PivotConfigUpdater + +| Name | Type | +| ------ | ------ | +| moveItem | (args: PivotConfigUpdaterArgs) => void | +| update | (pivotConfig: PivotConfig & PivotConfigExtraUpdateFields) => void | + +### PivotConfigUpdaterArgs + +| Name | Type | +| ------ | ------ | +| destinationAxis | TSourceAxis | +| destinationIndex | number | +| sourceAxis | TSourceAxis | +| sourceIndex | number | + +### SegmentUpdater + +``` + SegmentUpdater: MemberUpdater +``` + +### TLoadingState + +| Name | Type | +| ------ | ------ | +| isLoading | boolean | + +### TimeDimensionComparisonUpdateFields + +| Name | Type | +| ------ | ------ | +| compareDateRange | Array<DateRange> | +| dimension | TCubeDimension | +| granularity? | TimeDimensionGranularity | + +### TimeDimensionExtraFields + +| Name | Type | +| ------ | ------ | +| dimension | TCubeDimension & GranularityOptions | + +### TimeDimensionRangedUpdateFields + +| Name | Type | +| ------ | ------ | +| dateRange? | DateRange | +| dimension | TCubeDimension | +| granularity? | TimeDimensionGranularity | + +### TimeDimensionUpdater + +``` + TimeDimensionUpdater: MemberUpdater +``` + +### TimeDimensionWithExtraFields + +``` + TimeDimensionWithExtraFields: Omit & TimeDimensionExtraFields +``` + +### VizState + +| Name | Type | +| ------ | ------ | +| chartType? | ChartType | +| pivotConfig? | PivotConfig | +| query? | Query | diff --git a/docs/docs-new/pages/reference/frontend/cubejs-client-ws-transport.mdx b/docs/docs-new/pages/reference/frontend/cubejs-client-ws-transport.mdx new file mode 100644 index 0000000000000..6c7a2e9fb6f8a --- /dev/null +++ b/docs/docs-new/pages/reference/frontend/cubejs-client-ws-transport.mdx @@ -0,0 +1,132 @@ +# @cubejs-client/ws-transport + +WebSocket transport for Cube.js client + +## WebSocketTransport + +### constructor + +```typescript +new WebSocketTransport(__namedParameters: object): WebSocketTransport +``` + +### apiUrl + +``` + apiUrl: string +``` + +### heartBeatInterval + +``` + heartBeatInterval: number +``` + +### messageCounter + +``` + messageCounter: number +``` + +### messageIdToSubscription + +``` + messageIdToSubscription: Record +``` + +### messageQueue + +``` + messageQueue: Message[] +``` + +### token + +``` + token: string | undefined +``` + +### ws + +``` + ws: any +``` + +### authorization + +### close + +```typescript +close(): Promise +``` + +### initSocket + +```typescript +protected initSocket(): any +``` + +### request + +```typescript +request(method: string, __namedParameters: object): ITransportResponse +``` + +### sendMessage + +```typescript +protected sendMessage(message: any): void +``` + +## WebSocketTransportResult + +### constructor + +```typescript +new WebSocketTransportResult(__namedParameters: object): WebSocketTransportResult +``` + +### result + +``` + result: unknown +``` + +### status + +``` + status: unknown +``` + +### json + +```typescript +json(): Promise +``` + +## Types + +### Message + +| Name | Type | +| ------ | ------ | +| messageId | number | +| method | string | +| params | Record<string, unknown> | +| requestId | any | + +### Subscription + +| Name | Type | +| ------ | ------ | +| callback | (result: WebSocketTransportResult) => void | +| message | Message | + +### WebSocketTransportOptions + +| Name | Type | +| ------ | ------ | +| apiUrl | string | +| authorization? | string | +| hearBeatInterval? | number | +| heartBeatInterval? | number |