@volvo-cars/content-delivery-client
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export declare type ContentEnvironment = 'live' | 'authoringPreview' | 'master'; | ||
declare type ContentDeliveryDataSource = 'dotcom-sitecore-test' | 'dotcom-sitecore-qa' | 'dotcom-sitecore-prod' | string; | ||
export declare type ContentDeliveryDataSource = 'dotcom-sitecore-test' | 'dotcom-sitecore-qa' | 'dotcom-sitecore-prod' | string; | ||
export declare type ClientConfig = { | ||
@@ -18,6 +18,28 @@ /** | ||
/** | ||
* Default DataSource to fetch from. | ||
* Default data source to fetch content from. | ||
*/ | ||
defaultDataSource?: ContentDeliveryDataSource; | ||
/** | ||
* Default environment to fetch content from. | ||
* | ||
* @default 'live' | ||
*/ | ||
defaultEnvironment?: ContentEnvironment; | ||
/** | ||
* Allowed values for `dataSource` when fetching content. Can be an array or a | ||
* comma separated string. | ||
* | ||
* An operation with a `dataSource` not in the given list will throw an error. | ||
* If no value is given, any value can be passed as `dataSource` to operations. | ||
*/ | ||
allowedDataSources?: ContentDeliveryDataSource[] | string; | ||
/** | ||
* Allowed values for `environment` when fetching content. Can be an array or a | ||
* comma separated string. | ||
* | ||
* An operation with an `environment` not in the given list will throw an error. | ||
* If no value is given, any value can be passed as `environment` to operations. | ||
*/ | ||
allowedEnvironments?: ContentEnvironment[] | string; | ||
/** | ||
* The API key for your product. | ||
@@ -119,5 +141,4 @@ */ | ||
getEntry<T = unknown>(canonicalName: string, options: GetOptions): Promise<T>; | ||
listEntries(contentType: ContentType, options: GetOptions): Promise<ListEntriesResponseData>; | ||
listEntries<T extends ContentType>(contentType: T, options: GetOptions): Promise<ListEntriesResponseData<T>>; | ||
} | ||
export declare function createClient({ forceLocalData, fallbackToLocalData, ...config }: CreateClientOptions): ContentDeliveryClient; | ||
export {}; |
import { ClientConfig, GetOptions } from '../ContentDeliveryClient'; | ||
import { ContentType, ListEntriesResponseData } from './types'; | ||
export declare function listEntries<T = ListEntriesResponseData>(contentType: ContentType, config: ClientConfig, options: GetOptions): Promise<T>; | ||
export declare function listEntries<T extends ContentType>(contentType: T, config: ClientConfig, options: GetOptions): Promise<ListEntriesResponseData<T>>; |
@@ -0,4 +1,4 @@ | ||
import type { ContentEnvironment } from './ContentDeliveryClient'; | ||
import { DictionaryItems, FlattenedDictionaries } from './dictionaries/types'; | ||
import { RequestDetails } from './utils/sendRequest'; | ||
import { DictionaryItems, FlattenedDictionaries } from './dictionaries/types'; | ||
import type { ContentEnvironment } from './ContentDeliveryClient'; | ||
export declare class RequestError extends Error { | ||
@@ -10,2 +10,9 @@ name: string; | ||
} | ||
export declare class ContentDeliveryClientError extends Error { | ||
name: string; | ||
} | ||
export declare class ContentDeliveryClientValidationError extends ContentDeliveryClientError { | ||
name: string; | ||
constructor(actual: string, allowed: string[], type: string); | ||
} | ||
export declare class TimeoutError extends Error { | ||
@@ -12,0 +19,0 @@ name: string; |
@@ -14,4 +14,4 @@ import type { ClientConfig, ContentDeliveryClient, GetOptions } from './ContentDeliveryClient'; | ||
getEntry<T>(_canonicalName: string, _options: GetOptions): Promise<T>; | ||
listEntries(_contentType: ContentType, _options: GetOptions): Promise<ListEntriesResponseData>; | ||
listEntries<T extends ContentType>(_contentType: T, _options: GetOptions): Promise<ListEntriesResponseData<T>>; | ||
private flattenDictionaries; | ||
} |
@@ -1,6 +0,16 @@ | ||
import { ContentDeliveryClient, GetOptions } from './ContentDeliveryClient'; | ||
import { ClientConfig } from '.'; | ||
import { ContentDeliveryClient, ContentDeliveryDataSource, ContentEnvironment, GetOptions } from './ContentDeliveryClient'; | ||
import { FlattenedDictionaries } from './dictionaries/types'; | ||
import { ContentType, ListEntriesResponseData } from './entries/types'; | ||
import { LocalDataClient } from './LocalDataClient'; | ||
import { ContentType, ListEntriesResponseData } from './entries/types'; | ||
import { FlattenedDictionaries } from './dictionaries/types'; | ||
import { ClientConfig } from '.'; | ||
export declare type FinalClientConfig = Omit<ClientConfig, 'dataSource'> & { | ||
defaultEnvironment: ContentEnvironment; | ||
allowedDataSources: ContentDeliveryDataSource[]; | ||
allowedEnvironments: ContentEnvironment[]; | ||
revalidate: { | ||
dictionaries: number; | ||
entries: number; | ||
listEntries: number; | ||
}; | ||
}; | ||
export declare class RemoteDataClient implements ContentDeliveryClient { | ||
@@ -16,14 +26,11 @@ applicationId: string; | ||
private pendingRevalidations; | ||
private dictionariesRevalidate; | ||
private entriesRevalidate; | ||
private listEntriesRevalidate; | ||
constructor(config: ClientConfig, localDataClient?: LocalDataClient); | ||
get isValidating(): boolean; | ||
getDictionary(canonicalDictionaryName: string, options: GetOptions): Promise<FlattenedDictionaries>; | ||
getDictionaries(canonicalDictionaryNames: string[], options: GetOptions): Promise<FlattenedDictionaries>; | ||
getAllDictionaries(options: GetOptions): Promise<FlattenedDictionaries>; | ||
getEntry<T>(canonicalName: string, options: GetOptions): Promise<T>; | ||
listEntries(contentType: ContentType, options: GetOptions): Promise<ListEntriesResponseData>; | ||
getDictionary(canonicalDictionaryName: string, rawOptions: GetOptions): Promise<FlattenedDictionaries>; | ||
getDictionaries(canonicalDictionaryNames: string[], rawOptions: GetOptions): Promise<FlattenedDictionaries>; | ||
getAllDictionaries(rawOptions: GetOptions): Promise<FlattenedDictionaries>; | ||
getEntry<T>(canonicalName: string, rawOptions: GetOptions): Promise<T>; | ||
listEntries<T extends ContentType>(contentType: T, rawOptions: GetOptions): Promise<ListEntriesResponseData<T>>; | ||
private logError; | ||
private logFallback; | ||
} |
@@ -9,2 +9,6 @@ import type { ContentEnvironment } from '../ContentDeliveryClient'; | ||
}; | ||
declare type Now = typeof Date.now; | ||
interface CacheOptions { | ||
now?: Now; | ||
} | ||
export declare class Cache<Value = unknown> { | ||
@@ -14,2 +18,3 @@ lastUpdated: Map<string, number>; | ||
revalidateMs: number; | ||
now: Now; | ||
/** | ||
@@ -20,3 +25,3 @@ * | ||
*/ | ||
constructor(revalidate: number); | ||
constructor(revalidate: number, { now }?: CacheOptions); | ||
set(keyConfig: CacheKeyConfig, value: Value): void; | ||
@@ -29,2 +34,5 @@ has(keyConfig: CacheKeyConfig): boolean; | ||
isStale(keyConfig: CacheKeyConfig): boolean; | ||
delete(keyConfig: CacheKeyConfig): void; | ||
} | ||
export declare function getCacheKey(config: CacheKeyConfig): string; | ||
export {}; |
@@ -0,8 +1,8 @@ | ||
import type { ClientConfig, ContentEnvironment } from '../ContentDeliveryClient'; | ||
import type { ContentType } from '../entries/types'; | ||
import type { ContentEnvironment, ClientConfig } from '../ContentDeliveryClient'; | ||
export declare type RequestDetails = { | ||
applicationId: string; | ||
locale: string; | ||
environment: ContentEnvironment; | ||
dataSource?: string; | ||
environment?: ContentEnvironment; | ||
operationId?: string; | ||
@@ -18,3 +18,5 @@ market?: boolean; | ||
}; | ||
export declare function sendRequest<Results>({ applicationId, dataSource, path, market, locale, accept, environment, operationId, contentType, timeout, config, }: RequestDetails & SendRequestOptions): Promise<Results>; | ||
export declare function sendRequest<Results>({ applicationId, dataSource, path, market, locale, accept, environment, operationId, contentType, timeout, config, }: RequestDetails & SendRequestOptions, { retry }?: { | ||
retry?: boolean | undefined; | ||
}): Promise<Results>; | ||
export {}; |
{ | ||
"name": "@volvo-cars/content-delivery-client", | ||
"version": "0.1.0", | ||
"license": "UNLICENSED", | ||
"source": "index.ts", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts", | ||
"license": "UNLICENSED", | ||
"name": "@volvo-cars/content-delivery-client", | ||
"version": "0.0.3", | ||
"publishConfig": { | ||
"access": "public" | ||
"access": "public", | ||
"directory": "./package", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"files": [ | ||
"dist/**" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/volvo-cars/cdls-mono-volvocars.git", | ||
"directory": "packages/content-delivery-client" | ||
}, | ||
"scripts": { | ||
"build": "microbundle -f es,cjs --target node", | ||
"dev": "microbundle -f es,cjs --target node", | ||
"check-types": "tsc -b", | ||
"pack-unpack": "rm -rf package && yarn pack && tar zxf package.tgz", | ||
"pre-publish": "rm -rf dist && yarn build && yarn pack-unpack" | ||
}, | ||
"dependencies": { | ||
@@ -16,3 +34,12 @@ "@types/flat": "^5.0.1", | ||
"glob": "^7.0.0" | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"@vcc-www/testing": "0.0.0", | ||
"@vcc-www/utils": "0.0.0", | ||
"@volvo-cars/content-management-client": "0.9.2", | ||
"microbundle": "^0.14.2", | ||
"nock": "^13.0.5", | ||
"typescript": "*" | ||
}, | ||
"module": "dist/index.esm.js" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
47
2889
2
8
4
294769
6