contensis-core-api
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.8
@@ -22,8 +22,8 @@ import { isBrowser } from '../utils'; | ||
} | ||
else { | ||
if (!headers.clientId && !!params.clientId) { | ||
headers.clientId = params.clientId; | ||
headers.clientSecret = params.clientSecret; | ||
} | ||
if (params.clientType === "none" && !headers.accessToken) { | ||
throw new Error(`If the property clientType is set to "${params.clientType}" then the property accessToken must be provided.`); | ||
} | ||
if (params.clientType === 'client_credentials' && !params.clientDetails) { | ||
throw new Error(`If the property client type is set to "${params.clientType}" then the property clientDetails must be set to a ClientCredentialsGrant value.`); | ||
} | ||
if (!!params.defaultHeaders) { | ||
@@ -30,0 +30,0 @@ const keys = Object.keys(params.defaultHeaders); |
import { VersionStatus } from './VersionStatus'; | ||
import { ResponseHandler } from './ResponseHandler'; | ||
import { ClientGrantType, ClientGrants } from './ClientGrants'; | ||
export interface ClientParams { | ||
@@ -7,4 +8,4 @@ rootUrl: string; | ||
accessToken?: string; | ||
clientId?: string; | ||
clientSecret?: string; | ||
clientDetails?: ClientGrants; | ||
clientType?: ClientGrantType; | ||
defaultHeaders?: { | ||
@@ -11,0 +12,0 @@ [key: string]: string; |
export * from './AssetUpload'; | ||
export * from './ClientCredentialsGrant'; | ||
export * from './ClientError'; | ||
export * from './ClientGrants'; | ||
export * from './ClientParams'; | ||
export * from './ContensisClassicGrant'; | ||
export * from './Component'; | ||
@@ -5,0 +8,0 @@ export * from './ContensisQuery'; |
@@ -17,4 +17,6 @@ import { MapperFn } from './models'; | ||
export declare function isIE(): boolean; | ||
/** Checks if the runtime context is Node.js */ | ||
export declare function isNodejs(): boolean; | ||
export declare let defaultMapperForLanguage: MapperFn; | ||
export declare let defaultMapperForPublishedVersionStatus: MapperFn; | ||
export declare let defaultMapperForLatestVersionStatus: MapperFn; |
@@ -0,1 +1,2 @@ | ||
import * as isNode from 'detect-node'; | ||
export function hasProp(o, key) { | ||
@@ -33,4 +34,8 @@ return !!o && typeof o[key] !== 'undefined'; | ||
} | ||
/** Checks if the runtime context is Node.js */ | ||
export function isNodejs() { | ||
return isNode; | ||
} | ||
export let defaultMapperForLanguage = (value, options, params) => !value && !!params ? params.language : value; | ||
export let defaultMapperForPublishedVersionStatus = (value, options, params) => (value === 'published') ? null : value; | ||
export let defaultMapperForLatestVersionStatus = (value, options, params) => (value === 'latest') ? null : value; |
@@ -23,8 +23,8 @@ import { isBrowser } from '../utils'; | ||
} | ||
else { | ||
if (!headers.clientId && !!params.clientId) { | ||
headers.clientId = params.clientId; | ||
headers.clientSecret = params.clientSecret; | ||
} | ||
if (params.clientType === "none" && !headers.accessToken) { | ||
throw new Error("If the property clientType is set to \"" + params.clientType + "\" then the property accessToken must be provided."); | ||
} | ||
if (params.clientType === 'client_credentials' && !params.clientDetails) { | ||
throw new Error("If the property client type is set to \"" + params.clientType + "\" then the property clientDetails must be set to a ClientCredentialsGrant value."); | ||
} | ||
if (!!params.defaultHeaders) { | ||
@@ -31,0 +31,0 @@ var keys = Object.keys(params.defaultHeaders); |
import { VersionStatus } from './VersionStatus'; | ||
import { ResponseHandler } from './ResponseHandler'; | ||
import { ClientGrantType, ClientGrants } from './ClientGrants'; | ||
export interface ClientParams { | ||
@@ -7,4 +8,4 @@ rootUrl: string; | ||
accessToken?: string; | ||
clientId?: string; | ||
clientSecret?: string; | ||
clientDetails?: ClientGrants; | ||
clientType?: ClientGrantType; | ||
defaultHeaders?: { | ||
@@ -11,0 +12,0 @@ [key: string]: string; |
export * from './AssetUpload'; | ||
export * from './ClientCredentialsGrant'; | ||
export * from './ClientError'; | ||
export * from './ClientGrants'; | ||
export * from './ClientParams'; | ||
export * from './ContensisClassicGrant'; | ||
export * from './Component'; | ||
@@ -5,0 +8,0 @@ export * from './ContensisQuery'; |
@@ -17,4 +17,6 @@ import { MapperFn } from './models'; | ||
export declare function isIE(): boolean; | ||
/** Checks if the runtime context is Node.js */ | ||
export declare function isNodejs(): boolean; | ||
export declare let defaultMapperForLanguage: MapperFn; | ||
export declare let defaultMapperForPublishedVersionStatus: MapperFn; | ||
export declare let defaultMapperForLatestVersionStatus: MapperFn; |
@@ -0,1 +1,2 @@ | ||
import * as isNode from 'detect-node'; | ||
export function hasProp(o, key) { | ||
@@ -33,2 +34,6 @@ return !!o && typeof o[key] !== 'undefined'; | ||
} | ||
/** Checks if the runtime context is Node.js */ | ||
export function isNodejs() { | ||
return isNode; | ||
} | ||
export var defaultMapperForLanguage = function (value, options, params) { | ||
@@ -35,0 +40,0 @@ return !value && !!params ? params.language : value; |
@@ -7,7 +7,15 @@ # Changelog | ||
## [1.0.0-beta.6] - 2019-05-26 | ||
## [1.0.0-beta.8] - 2020-06-29 | ||
### Changed | ||
- added suport for 'contensis_classic' flow | ||
## [1.0.0-beta.7] - 2020-06-18 | ||
### Changed | ||
- added suport for multiple client types | ||
## [1.0.0-beta.6] - 2020-05-26 | ||
### Changed | ||
- the fetch function can now be injected to support better testing | ||
## [1.0.0-beta.5] - 2019-05-21 | ||
## [1.0.0-beta.5] - 2020-05-21 | ||
### Added | ||
@@ -14,0 +22,0 @@ - search query classes and interfaces |
@@ -25,8 +25,8 @@ "use strict"; | ||
} | ||
else { | ||
if (!headers.clientId && !!params.clientId) { | ||
headers.clientId = params.clientId; | ||
headers.clientSecret = params.clientSecret; | ||
} | ||
if (params.clientType === "none" && !headers.accessToken) { | ||
throw new Error("If the property clientType is set to \"" + params.clientType + "\" then the property accessToken must be provided."); | ||
} | ||
if (params.clientType === 'client_credentials' && !params.clientDetails) { | ||
throw new Error("If the property client type is set to \"" + params.clientType + "\" then the property clientDetails must be set to a ClientCredentialsGrant value."); | ||
} | ||
if (!!params.defaultHeaders) { | ||
@@ -33,0 +33,0 @@ var keys = Object.keys(params.defaultHeaders); |
import { VersionStatus } from './VersionStatus'; | ||
import { ResponseHandler } from './ResponseHandler'; | ||
import { ClientGrantType, ClientGrants } from './ClientGrants'; | ||
export interface ClientParams { | ||
@@ -7,4 +8,4 @@ rootUrl: string; | ||
accessToken?: string; | ||
clientId?: string; | ||
clientSecret?: string; | ||
clientDetails?: ClientGrants; | ||
clientType?: ClientGrantType; | ||
defaultHeaders?: { | ||
@@ -11,0 +12,0 @@ [key: string]: string; |
export * from './AssetUpload'; | ||
export * from './ClientCredentialsGrant'; | ||
export * from './ClientError'; | ||
export * from './ClientGrants'; | ||
export * from './ClientParams'; | ||
export * from './ContensisClassicGrant'; | ||
export * from './Component'; | ||
@@ -5,0 +8,0 @@ export * from './ContensisQuery'; |
@@ -17,4 +17,6 @@ import { MapperFn } from './models'; | ||
export declare function isIE(): boolean; | ||
/** Checks if the runtime context is Node.js */ | ||
export declare function isNodejs(): boolean; | ||
export declare let defaultMapperForLanguage: MapperFn; | ||
export declare let defaultMapperForPublishedVersionStatus: MapperFn; | ||
export declare let defaultMapperForLatestVersionStatus: MapperFn; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var isNode = require("detect-node"); | ||
function hasProp(o, key) { | ||
@@ -40,2 +41,7 @@ return !!o && typeof o[key] !== 'undefined'; | ||
exports.isIE = isIE; | ||
/** Checks if the runtime context is Node.js */ | ||
function isNodejs() { | ||
return isNode; | ||
} | ||
exports.isNodejs = isNodejs; | ||
exports.defaultMapperForLanguage = function (value, options, params) { | ||
@@ -42,0 +48,0 @@ return !value && !!params ? params.language : value; |
{ | ||
"name": "contensis-core-api", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.8", | ||
"description": "Contensis Core API Library ", | ||
@@ -50,2 +50,4 @@ "engines": { | ||
"dependencies": { | ||
"@types/detect-node": "^2.0.0", | ||
"detect-node": "^2.0.4", | ||
"es6-promise": "^4.2.6", | ||
@@ -52,0 +54,0 @@ "tslib": "^1.9.3" |
@@ -1,2 +0,2 @@ | ||
import { IParamsProvider, ClientError, ResponseHandlerFunction, IHttpClient } from '../models'; | ||
import { IParamsProvider, ClientError, ResponseHandlerFunction, IHttpClient, ClientCredentialsGrant } from '../models'; | ||
import { isBrowser } from '../utils'; | ||
@@ -28,9 +28,12 @@ | ||
headers.accessToken = params.accessToken; | ||
} else { | ||
if (!headers.clientId && !!params.clientId) { | ||
headers.clientId = params.clientId; | ||
headers.clientSecret = params.clientSecret; | ||
} | ||
} | ||
if(params.clientType === "none" && !headers.accessToken) { | ||
throw new Error(`If the property clientType is set to "${params.clientType}" then the property accessToken must be provided.`); | ||
} | ||
if(params.clientType === 'client_credentials' && !(params.clientDetails as ClientCredentialsGrant)) { | ||
throw new Error(`If the property client type is set to "${params.clientType}" then the property clientDetails must be set to a ClientCredentialsGrant value.`); | ||
} | ||
if (!!params.defaultHeaders) { | ||
@@ -37,0 +40,0 @@ const keys = Object.keys(params.defaultHeaders); |
import { VersionStatus } from './VersionStatus'; | ||
import { ResponseHandler } from './ResponseHandler'; | ||
import { ClientGrantType, ClientGrants } from './ClientGrants'; | ||
export interface ClientParams { | ||
@@ -7,4 +8,4 @@ rootUrl: string; | ||
accessToken?: string; | ||
clientId?: string; | ||
clientSecret?: string; | ||
clientDetails?: ClientGrants; | ||
clientType?: ClientGrantType; | ||
defaultHeaders?: { [key: string]: string }; | ||
@@ -11,0 +12,0 @@ language?: string; |
export * from './AssetUpload'; | ||
export * from './ClientCredentialsGrant'; | ||
export * from './ClientError'; | ||
export * from './ClientGrants'; | ||
export * from './ClientParams'; | ||
export * from './ContensisClassicGrant'; | ||
export * from './Component'; | ||
@@ -5,0 +8,0 @@ export * from './ContensisQuery'; |
import { MapperFn, ClientParams, VersionStatus } from './models'; | ||
import * as isNode from 'detect-node'; | ||
@@ -29,3 +30,2 @@ export function hasProp(o: any, key: string) { | ||
/** | ||
@@ -45,2 +45,7 @@ * Checks if the current browser is IE. | ||
/** Checks if the runtime context is Node.js */ | ||
export function isNodejs() : boolean{ | ||
return isNode; | ||
} | ||
export let defaultMapperForLanguage: MapperFn = (value: string, options: any, params: ClientParams) => | ||
@@ -47,0 +52,0 @@ !value && !!params ? params.language : value; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
170328
305
3861
4
+ Added@types/detect-node@^2.0.0
+ Addeddetect-node@^2.0.4
+ Added@types/detect-node@2.0.2(transitive)
+ Addeddetect-node@2.1.0(transitive)