diff --git a/packages/cubejs-client-core/src/index.ts b/packages/cubejs-client-core/src/index.ts index 5e91a1e8a2899..7e4cf669bad02 100644 --- a/packages/cubejs-client-core/src/index.ts +++ b/packages/cubejs-client-core/src/index.ts @@ -574,7 +574,7 @@ class CubeApi { () => this.request('load', { query, queryType: 'multi', - signal: options?.signal + signal: options?.signal, }), (response: any) => this.loadResponseInternal(response, options), options, diff --git a/packages/cubejs-client-core/src/types.ts b/packages/cubejs-client-core/src/types.ts index db50bd61fcd59..0750883e7e2ad 100644 --- a/packages/cubejs-client-core/src/types.ts +++ b/packages/cubejs-client-core/src/types.ts @@ -1,6 +1,5 @@ import Meta from './Meta'; import { TimeDimensionGranularity } from './time'; -import { TransportOptions } from './HttpTransport'; export type QueryOrder = 'asc' | 'desc' | 'none'; @@ -82,6 +81,33 @@ export type BinaryOperator = | 'afterDate' | 'afterOrOnDate'; +// NOTE: This type must be kept in sync with CacheMode in @cubejs-backend/shared (packages/cubejs-backend-shared/src/shared-types.ts) +// This duplication is intentional as @cubejs-client/core does not depend on @cubejs-backend/shared +/** + * Cache mode options for query execution. + * + * - **stale-if-slow** (default): Equivalent to previously used `renewQuery: false`. + * If refresh keys are up-to-date, returns the value from cache. + * If refresh keys are expired, tries to return the value from the database. + * Returns fresh value from the database if the query executed until the first "Continue wait" interval is reached. + * Returns stale value from cache otherwise. + * + * - **stale-while-revalidate**: AKA "backgroundRefresh". + * If refresh keys are up-to-date, returns the value from cache. + * If refresh keys are expired, returns stale data from cache. + * Updates the cache in background. + * + * - **must-revalidate**: Equivalent to previously used `renewQuery: true`. + * If refresh keys are up-to-date, returns the value from cache. + * If refresh keys are expired, tries to return the value from the database. + * Returns fresh value from the database even if it takes minutes and many "Continue wait" intervals. + * + * - **no-cache**: AKA "forceRefresh". + * Skips refresh key checks. + * Returns fresh data from the database, even if it takes minutes and many "Continue wait" intervals. + */ +export type CacheMode = 'stale-if-slow' | 'stale-while-revalidate' | 'must-revalidate' | 'no-cache'; + export interface BinaryFilter { /** * @deprecated Use `member` instead. @@ -115,6 +141,7 @@ export interface Query { timezone?: string; // @deprecated renewQuery?: boolean; + cache?: CacheMode; ungrouped?: boolean; responseFormat?: 'compact' | 'default'; total?: boolean; @@ -527,29 +554,4 @@ export type ProgressResponse = { timeElapsed: number; }; -// NOTE: This type must be kept in sync with CacheMode in @cubejs-backend/shared (packages/cubejs-backend-shared/src/shared-types.ts) -// This duplication is intentional as @cubejs-client/core does not depend on @cubejs-backend/shared -/** - * Cache mode options for query execution. - * - * - **stale-if-slow** (default): Equivalent to previously used `renewQuery: false`. - * If refresh keys are up-to-date, returns the value from cache. - * If refresh keys are expired, tries to return the value from the database. - * Returns fresh value from the database if the query executed until the first "Continue wait" interval is reached. - * Returns stale value from cache otherwise. - * - * - **stale-while-revalidate**: AKA "backgroundRefresh". - * If refresh keys are up-to-date, returns the value from cache. - * If refresh keys are expired, returns stale data from cache. - * Updates the cache in background. - * - * - **must-revalidate**: Equivalent to previously used `renewQuery: true`. - * If refresh keys are up-to-date, returns the value from cache. - * If refresh keys are expired, tries to return the value from the database. - * Returns fresh value from the database even if it takes minutes and many "Continue wait" intervals. - * - * - **no-cache**: AKA "forceRefresh". - * Skips refresh key checks. - * Returns fresh data from the database, even if it takes minutes and many "Continue wait" intervals. - */ -export type CacheMode = 'stale-if-slow' | 'stale-while-revalidate' | 'must-revalidate' | 'no-cache'; +