Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): change types to expose requestBatchSize [] #1149

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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>
@@ -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']
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'
marcolink marked this conversation as resolved.
Show resolved Hide resolved

// 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)
6 changes: 5 additions & 1 deletion src/lib/fetcher.ts
Original file line number Diff line number Diff line change
@@ -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)