Skip to content

Commit b07f55e

Browse files
committed
chore: rename csm alpha feature
1 parent b600e3f commit b07f55e

9 files changed

+38
-35
lines changed

lib/contentful.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export interface CreateClientParams {
119119
* @remarks
120120
* This feature is only available when using the Content Preview API.
121121
*/
122-
withContentSourceMaps?: boolean
122+
includeContentSourceMaps?: boolean
123123
}
124124
}
125125

lib/utils/validate-params.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ export function checkIncludeContentSourceMapsParamIsValid(alphaFeatures?: Record
5252
return false
5353
}
5454

55-
const isValidWithContentSourceMaps =
56-
'withContentSourceMaps' in alphaFeatures &&
57-
typeof alphaFeatures.withContentSourceMaps === 'boolean'
55+
const isValidIncludeContentSourceMaps =
56+
'includeContentSourceMaps' in alphaFeatures &&
57+
typeof alphaFeatures.includeContentSourceMaps === 'boolean'
5858

59-
if (!isValidWithContentSourceMaps) {
59+
if (!isValidIncludeContentSourceMaps) {
6060
throw new ValidationError(
61-
'withContentSourceMaps',
62-
`The 'withContentSourceMaps' parameter must be a boolean.`,
61+
'includeContentSourceMaps',
62+
`The 'includeContentSourceMaps' parameter must be a boolean.`,
6363
)
6464
}
6565

@@ -74,15 +74,18 @@ export function checkIncludeContentSourceMapsParamIsAllowed(
7474
return false
7575
}
7676

77-
const withContentSourceMapsIsAllowed = host === 'preview.contentful.com'
77+
const includeContentSourceMapsIsAllowed = host === 'preview.contentful.com'
7878

79-
if (checkIncludeContentSourceMapsParamIsValid(alphaFeatures) && !withContentSourceMapsIsAllowed) {
79+
if (
80+
checkIncludeContentSourceMapsParamIsValid(alphaFeatures) &&
81+
!includeContentSourceMapsIsAllowed
82+
) {
8083
throw new ValidationError(
81-
'withContentSourceMaps',
82-
`The 'withContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.
84+
'includeContentSourceMaps',
85+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.
8386
`,
8487
)
8588
}
8689

87-
return alphaFeatures.withContentSourceMaps as boolean
90+
return alphaFeatures.includeContentSourceMaps as boolean
8891
}

test/integration/getAsset.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (process.env.API_INTEGRATION_TESTS) {
1010
const client = contentful.createClient(params)
1111
const invalidClient = contentful.createClient({
1212
...params,
13-
alphaFeatures: { withContentSourceMaps: true },
13+
alphaFeatures: { includeContentSourceMaps: true },
1414
})
1515
const previewClient = contentful.createClient(previewParamsWithCSM)
1616

@@ -31,10 +31,10 @@ describe('getAsset', () => {
3131
expect(typeof response.fields.title).toBe('object')
3232
})
3333

34-
describe('has (alpha) withContentSourceMaps enabled', () => {
34+
describe('has (alpha) includeContentSourceMaps enabled', () => {
3535
test('cdn client', async () => {
3636
await expect(invalidClient.getAsset(asset)).rejects.toThrow(
37-
`The 'withContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
37+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
3838
)
3939
await expect(invalidClient.getAsset(asset)).rejects.toThrow(ValidationError)
4040
})

test/integration/getAssets.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (process.env.API_INTEGRATION_TESTS) {
1010
const client = contentful.createClient(params)
1111
const invalidClient = contentful.createClient({
1212
...params,
13-
alphaFeatures: { withContentSourceMaps: true },
13+
alphaFeatures: { includeContentSourceMaps: true },
1414
})
1515
const previewClient = contentful.createClient(previewParamsWithCSM)
1616

@@ -39,10 +39,10 @@ describe('getAssets', () => {
3939
})
4040
})
4141

42-
describe('has (alpha) withContentSourceMaps enabled', () => {
42+
describe('has (alpha) includeContentSourceMaps enabled', () => {
4343
test('cdn client', async () => {
4444
await expect(invalidClient.getAssets()).rejects.toThrow(
45-
`The 'withContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
45+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
4646
)
4747
await expect(invalidClient.getAssets()).rejects.toThrow(ValidationError)
4848
})

test/integration/getEntries.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (process.env.API_INTEGRATION_TESTS) {
1111
const client = contentful.createClient(params)
1212
const invalidClient = contentful.createClient({
1313
...params,
14-
alphaFeatures: { withContentSourceMaps: true },
14+
alphaFeatures: { includeContentSourceMaps: true },
1515
})
1616
const previewClient = contentful.createClient(previewParamsWithCSM)
1717

@@ -375,10 +375,10 @@ describe('getEntries via client chain modifiers', () => {
375375
})
376376
})
377377

378-
describe('has (alpha) withContentSourceMaps enabled', () => {
378+
describe('has (alpha) includeContentSourceMaps enabled', () => {
379379
test('invalid client', async () => {
380380
await expect(invalidClient.getEntries()).rejects.toThrow(
381-
`The 'withContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
381+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
382382
)
383383
await expect(invalidClient.getEntries()).rejects.toThrow(ValidationError)
384384
})

test/integration/getEntry.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (process.env.API_INTEGRATION_TESTS) {
1111
const client = contentful.createClient(params)
1212
const invalidClient = contentful.createClient({
1313
...params,
14-
alphaFeatures: { withContentSourceMaps: true },
14+
alphaFeatures: { includeContentSourceMaps: true },
1515
})
1616
const previewClient = contentful.createClient(previewParamsWithCSM)
1717
const localeClient = contentful.createClient(localeSpaceParams)
@@ -177,10 +177,10 @@ describe('getEntry via client chain modifiers', () => {
177177
})
178178
})
179179

180-
describe('preview client has (alpha) withContentSourceMaps enabled', () => {
180+
describe('preview client has (alpha) includeContentSourceMaps enabled', () => {
181181
test('invalid client', async () => {
182182
await expect(invalidClient.getEntry(entryWithResolvableLink)).rejects.toThrow(
183-
`The 'withContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
183+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
184184
)
185185
await expect(invalidClient.getEntry(entryWithResolvableLink)).rejects.toThrow(ValidationError)
186186
})

test/integration/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export const previewParams = {
1717

1818
export const previewParamsWithCSM = {
1919
...previewParams,
20-
alphaFeatures: { withContentSourceMaps: true },
20+
alphaFeatures: { includeContentSourceMaps: true },
2121
}

test/unit/contentful.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ describe('contentful', () => {
121121
createClient({
122122
accessToken: 'accessToken',
123123
space: 'spaceId',
124-
alphaFeatures: { withContentSourceMaps: true },
124+
alphaFeatures: { includeContentSourceMaps: true },
125125
})
126126
const callConfig = createHttpClientMock.mock.calls[0]
127127

128128
const alphaFeatures = callConfig[1].alphaFeatures
129-
expect(alphaFeatures).toEqual({ withContentSourceMaps: true })
129+
expect(alphaFeatures).toEqual({ includeContentSourceMaps: true })
130130
})
131131
})

test/unit/utils/validate-params.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ describe('checkIncludeContentSourceMapsParamIsValid', () => {
99
expect(checkIncludeContentSourceMapsParamIsValid()).toBe(false)
1010
})
1111

12-
it('throws ValidationError if withContentSourceMaps is not a boolean', () => {
12+
it('throws ValidationError if includeContentSourceMaps is not a boolean', () => {
1313
expect(() =>
14-
checkIncludeContentSourceMapsParamIsValid({ withContentSourceMaps: 'not a boolean' }),
14+
checkIncludeContentSourceMapsParamIsValid({ includeContentSourceMaps: 'not a boolean' }),
1515
).toThrow(ValidationError)
1616
})
1717

18-
it('returns true if withContentSourceMaps is a boolean', () => {
19-
expect(checkIncludeContentSourceMapsParamIsValid({ withContentSourceMaps: true })).toBe(true)
18+
it('returns true if includeContentSourceMaps is a boolean', () => {
19+
expect(checkIncludeContentSourceMapsParamIsValid({ includeContentSourceMaps: true })).toBe(true)
2020
})
2121
})
2222

@@ -26,18 +26,18 @@ describe('checkIncludeContentSourceMapsParamIsAllowed', () => {
2626
expect(checkIncludeContentSourceMapsParamIsAllowed('http://example.com', {})).toBe(false)
2727
})
2828

29-
it('throws ValidationError if withContentSourceMaps is valid but baseUrl does not include preview.contentful.com', () => {
29+
it('throws ValidationError if includeContentSourceMaps is valid but baseUrl does not include preview.contentful.com', () => {
3030
expect(() =>
3131
checkIncludeContentSourceMapsParamIsAllowed('cdn.contentful.com', {
32-
withContentSourceMaps: true,
32+
includeContentSourceMaps: true,
3333
}),
3434
).toThrow(ValidationError)
3535
})
3636

37-
it('returns true if withContentSourceMaps is valid and baseUrl includes preview.contentful.com', () => {
37+
it('returns true if includeContentSourceMaps is valid and baseUrl includes preview.contentful.com', () => {
3838
expect(
3939
checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', {
40-
withContentSourceMaps: true,
40+
includeContentSourceMaps: true,
4141
}),
4242
).toBe(true)
4343
})

0 commit comments

Comments
 (0)