@volvo-cars/content-delivery-client
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -109,2 +109,8 @@ /// <reference types="node" /> | ||
}; | ||
export declare type GetAllDictionariesOptions = GetOptions & { | ||
/** | ||
* Maximum number of dictionaries to return, defaults to 50. | ||
*/ | ||
limit?: number; | ||
}; | ||
export interface ContentDeliveryClient { | ||
@@ -138,3 +144,3 @@ /** | ||
*/ | ||
getAllDictionaries(options: GetOptions): Promise<FlattenedDictionaries>; | ||
getAllDictionaries(options: GetAllDictionariesOptions): Promise<FlattenedDictionaries>; | ||
getEntry<T = unknown>(canonicalName: string, options: GetOptions): Promise<T>; | ||
@@ -141,0 +147,0 @@ listEntries<T extends ContentType>(contentType: T, options: GetOptions): Promise<ListEntriesResponseData<T>>; |
import type { ClientConfig } from '..'; | ||
import type { GetOptions } from '../ContentDeliveryClient'; | ||
import type { GetAllDictionariesOptions, GetOptions } from '../ContentDeliveryClient'; | ||
import type { Dictionary } from './types'; | ||
export declare function fetchDictionary(canonicalDictionaryName: string, config: ClientConfig, options: GetOptions): Promise<Dictionary['items']>; | ||
export declare function fetchDictionaries(canonicalDictionaryNames: string[], config: ClientConfig, options: GetOptions): Promise<[string, Dictionary['items']][]>; | ||
export declare function fetchAllDictionaries(config: ClientConfig, options: GetOptions): Promise<[string, Dictionary['items']][]>; | ||
export declare function fetchAllDictionaries(config: ClientConfig, options: GetAllDictionariesOptions): Promise<[string, Dictionary['items']][]>; |
@@ -290,3 +290,4 @@ import flatten from 'flat'; | ||
timeout, | ||
config | ||
config, | ||
limit | ||
}, { | ||
@@ -328,2 +329,6 @@ retry = true | ||
if (limit) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
let fetchOptions = config.fetchOptions; | ||
@@ -420,3 +425,3 @@ | ||
return [canonicalDictionaryName, dictionary]; | ||
}))).filter(([_name, value]) => !!value); // If a single dictionary failed, throw an error but include the successful | ||
}))).filter(([, value]) => !!value); // If a single dictionary failed, throw an error but include the successful | ||
// fetches on the `data` property. | ||
@@ -513,3 +518,4 @@ | ||
environment: (_options$environment3 = options.environment) != null ? _options$environment3 : 'live', | ||
timeout: options.timeout | ||
timeout: options.timeout, | ||
limit: options.limit | ||
}; | ||
@@ -516,0 +522,0 @@ let results; |
@@ -314,3 +314,4 @@ var flatten = require('flat'); | ||
timeout, | ||
config | ||
config, | ||
limit | ||
}, { | ||
@@ -352,2 +353,6 @@ retry = true | ||
if (limit) { | ||
url.searchParams.set('limit', limit.toString()); | ||
} | ||
let fetchOptions = config.fetchOptions; | ||
@@ -444,3 +449,3 @@ | ||
return [canonicalDictionaryName, dictionary]; | ||
}))).filter(([_name, value]) => !!value); // If a single dictionary failed, throw an error but include the successful | ||
}))).filter(([, value]) => !!value); // If a single dictionary failed, throw an error but include the successful | ||
// fetches on the `data` property. | ||
@@ -537,3 +542,4 @@ | ||
environment: (_options$environment3 = options.environment) != null ? _options$environment3 : 'live', | ||
timeout: options.timeout | ||
timeout: options.timeout, | ||
limit: options.limit | ||
}; | ||
@@ -540,0 +546,0 @@ let results; |
import { ClientConfig } from '.'; | ||
import { ContentDeliveryClient, ContentDeliveryDataSource, ContentEnvironment, GetOptions } from './ContentDeliveryClient'; | ||
import { ContentDeliveryClient, ContentDeliveryDataSource, ContentEnvironment, GetAllDictionariesOptions, GetOptions } from './ContentDeliveryClient'; | ||
import { FlattenedDictionaries } from './dictionaries/types'; | ||
@@ -30,3 +30,3 @@ import { ContentType, ListEntriesResponseData } from './entries/types'; | ||
getDictionaries(canonicalDictionaryNames: string[], rawOptions: GetOptions): Promise<FlattenedDictionaries>; | ||
getAllDictionaries(rawOptions: GetOptions): Promise<FlattenedDictionaries>; | ||
getAllDictionaries(rawOptions: GetAllDictionariesOptions): Promise<FlattenedDictionaries>; | ||
getEntry<T>(canonicalName: string, rawOptions: GetOptions): Promise<T>; | ||
@@ -33,0 +33,0 @@ listEntries<T extends ContentType>(contentType: T, rawOptions: GetOptions): Promise<ListEntriesResponseData<T>>; |
@@ -12,2 +12,3 @@ import type { ClientConfig, ContentEnvironment } from '../ContentDeliveryClient'; | ||
timeout?: number; | ||
limit?: number; | ||
}; | ||
@@ -19,5 +20,5 @@ declare type SendRequestOptions = { | ||
}; | ||
export declare function sendRequest<Results>({ applicationId, dataSource, path, market, locale, accept, environment, operationId, contentType, timeout, config, }: RequestDetails & SendRequestOptions, { retry }?: { | ||
export declare function sendRequest<Results>({ applicationId, dataSource, path, market, locale, accept, environment, operationId, contentType, timeout, config, limit, }: RequestDetails & SendRequestOptions, { retry }?: { | ||
retry?: boolean | undefined; | ||
}): Promise<Results>; | ||
export {}; |
{ | ||
"name": "@volvo-cars/content-delivery-client", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"license": "UNLICENSED", | ||
@@ -31,3 +31,3 @@ "source": "index.ts", | ||
"@types/flat": "^5.0.1", | ||
"@volvo-cars/market-sites": "^1.3.0", | ||
"@volvo-cars/market-sites": "^1.4.0", | ||
"flat": "^5.0.0", | ||
@@ -34,0 +34,0 @@ "glob": "^7.0.0" |
@@ -182,10 +182,11 @@ # @volvo-cars/content-delivery-client | ||
// Everytime you update dictionaries with items, a mapItemsToParameters.json file will be | ||
// Everytime you update dictionaries with items, a DictionaryItemTypes file will be | ||
// written to ./config.path/. This will help with autocompleting and validating useTranslate hook. | ||
import mappedItems from '../src/content-management/mapItemsToParameters.json'; | ||
import { DictionaryItemTypes } from '../src/content-management/DictionaryItemTypes'; | ||
import { getDictionariesProvider } from '@vcc-www/react-translate'; | ||
export const { useTranslate, DictionariesProvider } = getDictionariesProvider< | ||
typeof mappedItems | ||
>(); | ||
export const { | ||
useTranslate, | ||
DictionariesProvider, | ||
} = getDictionariesProvider<DictionaryItemTypes>(); | ||
``` | ||
@@ -192,0 +193,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
307808
2947
316