Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parserConfig: ParserConfigOptions,
logger: LoggerOptions,
accessToken: string
) {
this.apiConfig = apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
fetch,
}),
],
})
const defaultConfig = {
categoryBy: 'name', // key, externalId or namedPath supported
categoryOrderHintBy: 'name', // key, externalId or name supported
delimiter: ',',
fillAllRows: false,
onlyMasterVariants: false,
language: 'en',
languages: ['en'],
multiValueDelimiter: ';',
encoding: 'utf8',
describe('Anonymous Session Flow', () => {
const httpMiddleware = createHttpMiddleware({
host: 'https://api.sphere.io',
fetch,
})
it('create an anonymous session and a cart tied to the session', () => {
const authConfig = {
...apiConfig,
...{ scopes: [`manage_project:${projectKey}`] },
...{
credentials: {
clientId: apiConfig.credentials.clientId,
clientSecret: apiConfig.credentials.clientSecret,
},
},
fetch,
}
describe('Channels', () => {
const ignoredResponseKeys = [
'id',
'createdAt',
'createdBy',
'lastModifiedAt',
'lastModifiedBy',
]
const service = createRequestBuilder({ projectKey }).channels
const httpMiddleware = createHttpMiddleware({
host: 'https://api.sphere.io',
fetch,
})
const queueMiddleware = createQueueMiddleware({
concurrency: 5,
})
const userAgentMiddleware = createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
contactUrl: 'https://github.com/commercetools/nodejs',
contactEmail: 'npmjs@commercetools.com',
})
const key = uniqueId('channel_')
let channelResponse
let client
let apiConfig
exportConfig: ExportConfigOptions,
logger: LoggerOptions,
accessToken: string
) {
this.apiConfig = apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
})
const defaultConfig = { staged: false, json: true }
this.exportConfig = { ...defaultConfig, ...exportConfig }
this.logger = {
error: () => {},
warn: () => {},
info: () => {},
debug: () => {},
...logger,
)
this.apiConfig = options.apiConfig
this.accessToken = options.accessToken
this.batchSize = options.batchSize || 50
this.continueOnProblems = options.continueOnProblems || false
this.client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
fetch,
}),
],
})
this.syncDiscountCodes = createSyncDiscountCodes()
this.logger = logger || {
error: npmlog.error.bind(this, ''),
warn: npmlog.warn.bind(this, ''),
info: npmlog.info.bind(this, ''),
verbose: npmlog.verbose.bind(this, ''),
}
this._resetSummary()
}
apiConfig: ApiConfigOptions,
accessToken: string
): Object {
if (!apiConfig)
throw new Error('The constructor must be passed an `apiConfig` object')
return createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
accessToken ? `Bearer ${accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({ ...apiConfig, fetch }),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: apiConfig.apiUrl,
fetch,
}),
],
})
}
if (!options.apiConfig)
throw new Error('The contructor must be passed an `apiConfig` object')
if (options.batchSize > 500)
throw new Error('The `batchSize` must not be more than 500')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
})
const defaultOptions = {
delimiter: ',',
multiValueDelimiter: ';',
batchSize: 500,
exportFormat: 'json',
language: 'en',
fields: [],
}
throw new Error('The constructor must be passed an `apiConfig` object')
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
})
this.predicate = options.predicate
this.logger = {
...silentLogger,
...options.logger,
}
}
this.logger = {
error: () => {},
info: () => {},
warn: () => {},
verbose: () => {},
...logger,
}
this.client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({ ...apiConfig, fetch }),
createUserAgentMiddleware({
libraryName: name,
libraryVersion: version,
}),
createHttpMiddleware({
host: apiConfig.apiUrl,
enableRetry: true,
fetch,
}),
],
})
this.exportConfig = exportConfig
this.accessToken = accessToken
this.reqBuilder = createRequestBuilder({
projectKey: apiConfig.projectKey,
})
}
this.apiConfig = options.apiConfig
this.client = createClient({
middlewares: [
createAuthMiddlewareWithExistingToken(
options.accessToken ? `Bearer ${options.accessToken}` : ''
),
createAuthMiddlewareForClientCredentialsFlow({
...this.apiConfig,
fetch,
}),
createUserAgentMiddleware({
libraryName: pkg.name,
libraryVersion: pkg.version,
}),
createHttpMiddleware({
host: this.apiConfig.apiUrl,
fetch,
}),
],
})
this.batchSize = options.batchSize || 50
this.continueOnProblems = options.continueOnProblems || false
this.logger = {
...silentLogger,
...options.logger,
}
this._initiateSummary()
}