Skip to content

Commit

Permalink
Merge pull request #1149 from contentful/fix/requestBatchSize-types
Browse files Browse the repository at this point in the history
  • Loading branch information
andreascful authored Dec 1, 2022
2 parents 09e7be2 + d5d633d commit 0dbb222
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type RunMigrationConfig = {
rawProxy?: boolean
yes?: boolean
retryLimit?: number
requestBatchSize?: number
} & ({ filePath: string } | { migrationFunction: MigrationFunction })

export function runMigration(config: RunMigrationConfig): Promise<any>
Expand Down Expand Up @@ -639,6 +640,9 @@ export interface ClientConfig {
environmentId?: string
proxy?: string
rawProxy?: boolean
requestBatchSize?: number
headers?: Record<string, unknown>
retryLimit?: number
}

export type MakeRequest = (requestConfig: axios.AxiosRequestConfig) => axios.AxiosResponse['data']
Expand Down
12 changes: 1 addition & 11 deletions src/bin/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import * as path from 'path'
import * as os from 'os'
import { v4 as uuidv4 } from 'uuid'
import type { ClientConfig } from '../../../index'

// TODO: I'm ugly, maybe change me
const homedir = process.env.NODE_ENV === 'test' ? '/tmp' : os.homedir()
const configPath = path.resolve(homedir, '.contentfulrc.json')

interface ClientConfig {
accessToken?: string
spaceId?: string
environmentId?: string
proxy?: string
rawProxy?: boolean
requestBatchSize?: number
headers?: Record<string, unknown>
retryLimit?: number
}

function getFileConfig(): ClientConfig {
try {
const config = require(configPath)
Expand Down
6 changes: 5 additions & 1 deletion src/lib/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export default class Fetcher implements APIFetcher {
const ids: string[] = _.uniq(
intentList
.getIntents()
.filter((intent) => (!intent.isEditorInterfaceIntent() || intent.requiresContentType()) && !intent.isTagIntent())
.filter(
(intent) =>
(!intent.isEditorInterfaceIntent() || intent.requiresContentType()) &&
!intent.isTagIntent()
)
.reduce((ids, intent) => {
const intentIds = intent.getRelatedContentTypeIds()
return ids.concat(intentIds)
Expand Down

0 comments on commit 0dbb222

Please sign in to comment.