Skip to content

Commit d2ed401

Browse files
authored
fix: align types to API and normalize naming (#2375)
1 parent dd4e663 commit d2ed401

14 files changed

+110
-107
lines changed

lib/adapters/REST/endpoints/access-token.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AxiosInstance } from 'contentful-sdk-core'
33
import type { CollectionProp, GetOrganizationParams, QueryParams } from '../../../common-types'
44
import type {
55
CreatePersonalAccessTokenProps,
6-
AccessTokenProp,
6+
AccessTokenProps,
77
} from '../../../entities/access-token'
88
import type { RestEndpoint } from '../types'
99
import * as raw from './raw'
@@ -14,7 +14,7 @@ import * as raw from './raw'
1414
* @param {AxiosInstance} http - An Axios HTTP client instance.
1515
* @param {Object} params - Parameters for the request.
1616
* @param {string} params.tokenId - The unique token ID of the access token to retrieve.
17-
* @returns {Promise<AccessTokenProp>} A Promise that resolves with the retrieved access token information.
17+
* @returns {Promise<AccessTokenProps>} A Promise that resolves with the retrieved access token information.
1818
* @example ```javascript
1919
* const contentful = require('contentful-management')
2020
*
@@ -33,15 +33,15 @@ export const get: RestEndpoint<'AccessToken', 'get'> = (
3333
http: AxiosInstance,
3434
params: { tokenId: string }
3535
) => {
36-
return raw.get<AccessTokenProp>(http, `/users/me/access_tokens/${params.tokenId}`)
36+
return raw.get<AccessTokenProps>(http, `/users/me/access_tokens/${params.tokenId}`)
3737
}
3838

3939
/**
4040
* Retrieves multiple access tokens associated with the currently authenticated user.
4141
*
4242
* @param {AxiosInstance} http - An Axios HTTP client instance.
4343
* @param {QueryParams} params - Query parameters to filter and customize the request.
44-
* @returns {Promise<CollectionProp<AccessTokenProp>>} A Promise that resolves with a collection of access token properties.
44+
* @returns {Promise<CollectionProp<AccessTokenProps>>} A Promise that resolves with a collection of access token properties.
4545
* @example ```javascript
4646
* const contentful = require('contentful-management')
4747
*
@@ -60,7 +60,7 @@ export const getMany: RestEndpoint<'AccessToken', 'getMany'> = (
6060
http: AxiosInstance,
6161
params: QueryParams
6262
) => {
63-
return raw.get<CollectionProp<AccessTokenProp>>(http, '/users/me/access_tokens', {
63+
return raw.get<CollectionProp<AccessTokenProps>>(http, '/users/me/access_tokens', {
6464
params: params.query,
6565
})
6666
}
@@ -72,7 +72,7 @@ export const getMany: RestEndpoint<'AccessToken', 'getMany'> = (
7272
* @param {Object} _params - Unused parameters (can be an empty object).
7373
* @param {CreatePersonalAccessTokenProps} rawData - Data for creating the personal access token.
7474
* @param {RawAxiosRequestHeaders} [headers] - Optional HTTP headers for the request.
75-
* @returns {Promise<AccessTokenProp>} A Promise that resolves with the created personal access token.
75+
* @returns {Promise<AccessTokenProps>} A Promise that resolves with the created personal access token.
7676
* @example ```javascript
7777
* const contentful = require('contentful-management')
7878
*
@@ -93,7 +93,7 @@ export const createPersonalAccessToken: RestEndpoint<'AccessToken', 'createPerso
9393
rawData: CreatePersonalAccessTokenProps,
9494
headers?: RawAxiosRequestHeaders
9595
) => {
96-
return raw.post<AccessTokenProp>(http, '/users/me/access_tokens', rawData, {
96+
return raw.post<AccessTokenProps>(http, '/users/me/access_tokens', rawData, {
9797
headers,
9898
})
9999
}
@@ -104,7 +104,7 @@ export const createPersonalAccessToken: RestEndpoint<'AccessToken', 'createPerso
104104
* @param {AxiosInstance} http - The Axios HTTP client instance.
105105
* @param {Object} params - The parameters for revoking the access token.
106106
* @param {string} params.tokenId - The unique identifier of the access token to revoke.
107-
* @returns {Promise<AccessTokenProp>} A Promise that resolves with the updated access token information after revocation.
107+
* @returns {Promise<AccessTokenProps>} A Promise that resolves with the updated access token information after revocation.
108108
* @example ```javascript
109109
* const contentful = require('contentful-management')
110110
*
@@ -123,7 +123,7 @@ export const revoke: RestEndpoint<'AccessToken', 'revoke'> = (
123123
http: AxiosInstance,
124124
params: { tokenId: string }
125125
) => {
126-
return raw.put<AccessTokenProp>(http, `/users/me/access_tokens/${params.tokenId}/revoked`, null)
126+
return raw.put<AccessTokenProps>(http, `/users/me/access_tokens/${params.tokenId}/revoked`, null)
127127
}
128128

129129
/**
@@ -132,7 +132,7 @@ export const revoke: RestEndpoint<'AccessToken', 'revoke'> = (
132132
* @param {AxiosInstance} http - The Axios HTTP client instance.
133133
* @param {GetOrganizationParams & QueryParams} params - Parameters for the request, including organization ID and query parameters.
134134
* @param {string} params.organizationId - The unique identifier of the organization.
135-
* @returns {Promise<CollectionProp<AccessTokenProp>>} A promise that resolves to a collection of access tokens.
135+
* @returns {Promise<CollectionProp<AccessTokenProps>>} A promise that resolves to a collection of access tokens.
136136
* @example ```javascript
137137
* const contentful = require('contentful-management')
138138
*
@@ -151,7 +151,7 @@ export const getManyForOrganization: RestEndpoint<'AccessToken', 'getManyForOrga
151151
http: AxiosInstance,
152152
params: GetOrganizationParams & QueryParams
153153
) => {
154-
return raw.get<CollectionProp<AccessTokenProp>>(
154+
return raw.get<CollectionProp<AccessTokenProps>>(
155155
http,
156156
`/organizations/${params.organizationId}/access_tokens`,
157157
{

lib/adapters/REST/endpoints/organization.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import type {
44
GetOrganizationParams,
55
PaginationQueryParams,
66
} from '../../../common-types'
7-
import type { OrganizationProp } from '../../../entities/organization'
7+
import type { OrganizationProps } from '../../../entities/organization'
88
import type { RestEndpoint } from '../types'
99
import * as raw from './raw'
1010

1111
export const getMany: RestEndpoint<'Organization', 'getMany'> = (
1212
http: AxiosInstance,
1313
params?: PaginationQueryParams
1414
) => {
15-
return raw.get<CollectionProp<OrganizationProp>>(http, `/organizations`, {
15+
return raw.get<CollectionProp<OrganizationProps>>(http, `/organizations`, {
1616
params: params?.query,
1717
})
1818
}

lib/adapters/REST/endpoints/personal-access-token.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AxiosInstance } from 'contentful-sdk-core'
33
import type { CollectionProp, QueryParams } from '../../../common-types'
44
import type {
55
CreatePersonalAccessTokenProps,
6-
PersonalAccessTokenProp,
6+
PersonalAccessTokenProps,
77
} from '../../../entities/personal-access-token'
88
import type { RestEndpoint } from '../types'
99
import * as raw from './raw'
@@ -15,7 +15,7 @@ export const get: RestEndpoint<'PersonalAccessToken', 'get'> = (
1515
http: AxiosInstance,
1616
params: { tokenId: string }
1717
) => {
18-
return raw.get<PersonalAccessTokenProp>(http, `/users/me/access_tokens/${params.tokenId}`)
18+
return raw.get<PersonalAccessTokenProps>(http, `/users/me/access_tokens/${params.tokenId}`)
1919
}
2020

2121
/**
@@ -25,7 +25,7 @@ export const getMany: RestEndpoint<'PersonalAccessToken', 'getMany'> = (
2525
http: AxiosInstance,
2626
params: QueryParams
2727
) => {
28-
return raw.get<CollectionProp<PersonalAccessTokenProp>>(http, '/users/me/access_tokens', {
28+
return raw.get<CollectionProp<PersonalAccessTokenProps>>(http, '/users/me/access_tokens', {
2929
params: params.query,
3030
})
3131
}
@@ -39,7 +39,7 @@ export const create: RestEndpoint<'PersonalAccessToken', 'create'> = (
3939
rawData: CreatePersonalAccessTokenProps,
4040
headers?: RawAxiosRequestHeaders
4141
) => {
42-
return raw.post<PersonalAccessTokenProp>(http, '/users/me/access_tokens', rawData, {
42+
return raw.post<PersonalAccessTokenProps>(http, '/users/me/access_tokens', rawData, {
4343
headers,
4444
})
4545
}
@@ -51,7 +51,7 @@ export const revoke: RestEndpoint<'PersonalAccessToken', 'revoke'> = (
5151
http: AxiosInstance,
5252
params: { tokenId: string }
5353
) => {
54-
return raw.put<PersonalAccessTokenProp>(
54+
return raw.put<PersonalAccessTokenProps>(
5555
http,
5656
`/users/me/access_tokens/${params.tokenId}/revoked`,
5757
null

lib/common-types.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ import type {
4141
} from './entities/environment-alias'
4242
import type { CreateLocaleProps, LocaleProps } from './entities/locale'
4343
import type { AppInstallationsForOrganizationProps } from './entities/app-definition'
44-
import type { OrganizationProp } from './entities/organization'
44+
import type { OrganizationProps } from './entities/organization'
4545
import type {
4646
CreateOrganizationInvitationProps,
4747
OrganizationInvitationProps,
4848
} from './entities/organization-invitation'
4949
import type { OrganizationMembershipProps } from './entities/organization-membership'
5050
import type {
5151
CreatePersonalAccessTokenProps,
52-
PersonalAccessTokenProp,
52+
PersonalAccessTokenProps,
5353
} from './entities/personal-access-token'
5454
import type {
55-
AccessTokenProp,
55+
AccessTokenProps,
5656
CreatePersonalAccessTokenProps as CreatePATProps,
5757
} from './entities/access-token'
5858
import type { PreviewApiKeyProps } from './entities/preview-api-key'
@@ -246,7 +246,6 @@ export interface BasicMetaSysProps {
246246

247247
export interface MetaSysProps extends BasicMetaSysProps {
248248
space?: SysLink
249-
status?: SysLink
250249
publishedVersion?: number
251250
archivedVersion?: number
252251
archivedBy?: SysLink
@@ -258,7 +257,7 @@ export interface MetaSysProps extends BasicMetaSysProps {
258257

259258
export interface EntityMetaSysProps extends MetaSysProps {
260259
space: SysLink
261-
contentType: SysLink
260+
status?: SysLink
262261
environment: SysLink
263262
publishedBy?: Link<'User'> | Link<'AppDefinition'>
264263
publishedAt?: string
@@ -268,6 +267,7 @@ export interface EntityMetaSysProps extends MetaSysProps {
268267
}
269268

270269
export interface EntryMetaSysProps extends EntityMetaSysProps {
270+
contentType: SysLink
271271
automationTags: Link<'Tag'>[]
272272
}
273273

@@ -1515,8 +1515,8 @@ export type MRActions = {
15151515
}
15161516
}
15171517
Organization: {
1518-
getMany: { params: PaginationQueryParams; return: CollectionProp<OrganizationProp> }
1519-
get: { params: GetOrganizationParams; return: OrganizationProp }
1518+
getMany: { params: PaginationQueryParams; return: CollectionProp<OrganizationProps> }
1519+
get: { params: GetOrganizationParams; return: OrganizationProps }
15201520
}
15211521
OrganizationInvitation: {
15221522
get: {
@@ -1546,29 +1546,29 @@ export type MRActions = {
15461546
delete: { params: GetOrganizationMembershipParams; return: any }
15471547
}
15481548
PersonalAccessToken: {
1549-
get: { params: { tokenId: string }; return: PersonalAccessTokenProp }
1550-
getMany: { params: QueryParams; return: CollectionProp<PersonalAccessTokenProp> }
1549+
get: { params: { tokenId: string }; return: PersonalAccessTokenProps }
1550+
getMany: { params: QueryParams; return: CollectionProp<PersonalAccessTokenProps> }
15511551
create: {
15521552
params: {}
15531553
payload: CreatePersonalAccessTokenProps
15541554
headers?: RawAxiosRequestHeaders
1555-
return: PersonalAccessTokenProp
1555+
return: PersonalAccessTokenProps
15561556
}
1557-
revoke: { params: { tokenId: string }; return: PersonalAccessTokenProp }
1557+
revoke: { params: { tokenId: string }; return: PersonalAccessTokenProps }
15581558
}
15591559
AccessToken: {
1560-
get: { params: { tokenId: string }; return: AccessTokenProp }
1561-
getMany: { params: QueryParams; return: CollectionProp<AccessTokenProp> }
1560+
get: { params: { tokenId: string }; return: AccessTokenProps }
1561+
getMany: { params: QueryParams; return: CollectionProp<AccessTokenProps> }
15621562
createPersonalAccessToken: {
15631563
params: {}
15641564
payload: CreatePATProps
15651565
headers?: RawAxiosRequestHeaders
1566-
return: AccessTokenProp
1566+
return: AccessTokenProps
15671567
}
1568-
revoke: { params: { tokenId: string }; return: AccessTokenProp }
1568+
revoke: { params: { tokenId: string }; return: AccessTokenProps }
15691569
getManyForOrganization: {
15701570
params: GetOrganizationParams & QueryParams
1571-
return: CollectionProp<AccessTokenProp>
1571+
return: CollectionProp<AccessTokenProps>
15721572
}
15731573
}
15741574
PreviewApiKey: {

lib/create-contentful-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
BasicCursorPaginationOptions,
1212
} from './common-types'
1313
import entities from './entities'
14-
import type { Organization, OrganizationProp } from './entities/organization'
14+
import type { Organization, OrganizationProps } from './entities/organization'
1515
import type { CreatePersonalAccessTokenProps } from './entities/personal-access-token'
1616
import type { Space, SpaceProps } from './entities/space'
1717
import type { AppDefinition } from './entities/app-definition'
@@ -260,7 +260,7 @@ export default function createClientApi(makeRequest: MakeRequest) {
260260
*/
261261
getOrganizations: function getOrganizations(
262262
query: PaginationQueryParams['query'] = {}
263-
): Promise<Collection<Organization, OrganizationProp>> {
263+
): Promise<Collection<Organization, OrganizationProps>> {
264264
return makeRequest({
265265
entityType: 'Organization',
266266
action: 'getMany',

0 commit comments

Comments
 (0)