Skip to content

Commit 26808dd

Browse files
tylerpinaclaude
andauthored
feat: introduce ExoCursorPaginatedCollectionProp for ExO endpoints [DX-1016] (#3020)
* feat: define ExoCursorPaginatedCollectionProp in common-types [DX-1016] * feat: update ExO collection type aliases to use ExoCursorPaginatedCollectionProp [DX-1016] Replaces CursorPaginatedCollectionProp with ExoCursorPaginatedCollectionProp in: - ExperienceCollection - FragmentCollection - TemplateCollection - ComponentTypeCollection - DataAssemblyCollection (newly added with error handling for not-found IDs) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: update ExO REST endpoint type parameters [DX-1016] Update REST adapter endpoint files to use ExoCursorPaginatedCollectionProp for Experience, Fragment, Template, and ComponentType list operations. DataAssembly uses DataAssemblyCollection for its two list endpoints (public and private). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: update ExO plain client getMany return types [DX-1016] * feat: export ExoCursorPaginatedCollectionProp, DataAssemblyCollection, FragmentCollection [DX-1016] * chore: prettier * chore: type aliases updated * chore: prettier * chore: type import * chore: prettier --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b471e10 commit 26808dd

17 files changed

Lines changed: 66 additions & 61 deletions

lib/adapters/REST/endpoints/component-type.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import type { RawAxiosRequestHeaders } from 'axios'
22
import type { AxiosInstance } from 'contentful-sdk-core'
33
import copy from 'fast-copy'
44
import type { SetOptional } from 'type-fest'
5+
import type { GetComponentTypeParams, GetSpaceEnvironmentParams } from '../../../common-types'
56
import type {
6-
CursorPaginatedCollectionProp,
7-
GetComponentTypeParams,
8-
GetSpaceEnvironmentParams,
9-
} from '../../../common-types'
10-
import type {
7+
ComponentTypeCollection,
118
ComponentTypeProps,
129
ComponentTypeQueryOptions,
1310
CreateComponentTypeProps,
@@ -24,7 +21,7 @@ export const getMany: RestEndpoint<'ComponentType', 'getMany'> = (
2421
params: GetSpaceEnvironmentParams & { query: ComponentTypeQueryOptions },
2522
headers?: RawAxiosRequestHeaders,
2623
) => {
27-
return raw.get<CursorPaginatedCollectionProp<ComponentTypeProps>>(http, getBaseUrl(params), {
24+
return raw.get<ComponentTypeCollection>(http, getBaseUrl(params), {
2825
params: params.query,
2926
headers,
3027
})

lib/adapters/REST/endpoints/data-assembly.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import type { RawAxiosRequestHeaders } from 'axios'
22
import type { AxiosInstance } from 'contentful-sdk-core'
33
import copy from 'fast-copy'
4-
import type {
5-
CursorPaginatedCollectionProp,
6-
GetDataAssemblyParams,
7-
GetSpaceEnvironmentParams,
8-
} from '../../../common-types'
4+
import type { GetDataAssemblyParams, GetSpaceEnvironmentParams } from '../../../common-types'
95
import type {
106
CreateDataAssemblyProps,
7+
DataAssemblyCollection,
118
DataAssemblyProps,
129
DataAssemblyQueryOptions,
1310
UpdateDataAssemblyProps,
@@ -26,7 +23,7 @@ export const getMany: RestEndpoint<'DataAssembly', 'getMany'> = (
2623
params: GetSpaceEnvironmentParams & { query: DataAssemblyQueryOptions },
2724
headers?: RawAxiosRequestHeaders,
2825
) => {
29-
return raw.get<CursorPaginatedCollectionProp<DataAssemblyProps>>(http, getBaseUrl(params), {
26+
return raw.get<DataAssemblyCollection>(http, getBaseUrl(params), {
3027
params: params.query,
3128
headers,
3229
})
@@ -102,7 +99,7 @@ export const getManyPublished: RestEndpoint<'DataAssembly', 'getManyPublished'>
10299
params: GetSpaceEnvironmentParams & { query: DataAssemblyQueryOptions },
103100
headers?: RawAxiosRequestHeaders,
104101
) => {
105-
return raw.get<CursorPaginatedCollectionProp<DataAssemblyProps>>(http, getPublicUrl(params), {
102+
return raw.get<DataAssemblyCollection>(http, getPublicUrl(params), {
106103
params: params.query,
107104
headers,
108105
})

lib/adapters/REST/endpoints/experience.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import type { RawAxiosRequestHeaders } from 'axios'
22
import type { AxiosInstance } from 'contentful-sdk-core'
33
import copy from 'fast-copy'
44
import type { SetOptional } from 'type-fest'
5-
import type {
6-
CursorPaginatedCollectionProp,
7-
GetSpaceEnvironmentParams,
8-
GetExperienceParams,
9-
} from '../../../common-types'
5+
import type { GetSpaceEnvironmentParams, GetExperienceParams } from '../../../common-types'
106
import type {
117
CreateExperienceProps,
128
UpdateExperienceProps,
139
ExperienceLocalePublishPayload,
1410
ExperienceProps,
1511
ExperienceQueryOptions,
12+
ExperienceCollection,
1613
} from '../../../entities/experience'
1714
import type { RestEndpoint } from '../types'
1815
import * as raw from './raw'
@@ -25,7 +22,7 @@ export const getMany: RestEndpoint<'Experience', 'getMany'> = (
2522
params: GetSpaceEnvironmentParams & { query: ExperienceQueryOptions },
2623
headers?: RawAxiosRequestHeaders,
2724
) => {
28-
return raw.get<CursorPaginatedCollectionProp<ExperienceProps>>(http, getBaseUrl(params), {
25+
return raw.get<ExperienceCollection>(http, getBaseUrl(params), {
2926
params: params.query,
3027
headers,
3128
})

lib/adapters/REST/endpoints/fragment.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import type { RawAxiosRequestHeaders } from 'axios'
22
import type { AxiosInstance } from 'contentful-sdk-core'
33
import copy from 'fast-copy'
44
import type { SetOptional } from 'type-fest'
5-
import type {
6-
CursorPaginatedCollectionProp,
7-
GetFragmentParams,
8-
GetSpaceEnvironmentParams,
9-
} from '../../../common-types'
5+
import type { GetFragmentParams, GetSpaceEnvironmentParams } from '../../../common-types'
106
import type {
117
CreateFragmentProps,
128
FragmentProps,
139
FragmentQueryOptions,
1410
UpdateFragmentProps,
11+
FragmentCollection,
1512
} from '../../../entities/fragment'
1613
import type { RestEndpoint } from '../types'
1714
import * as raw from './raw'
@@ -24,7 +21,7 @@ export const getMany: RestEndpoint<'Fragment', 'getMany'> = (
2421
params: GetSpaceEnvironmentParams & { query: FragmentQueryOptions },
2522
headers?: RawAxiosRequestHeaders,
2623
) => {
27-
return raw.get<CursorPaginatedCollectionProp<FragmentProps>>(http, getBaseUrl(params), {
24+
return raw.get<FragmentCollection>(http, getBaseUrl(params), {
2825
params: params.query,
2926
headers,
3027
})

lib/adapters/REST/endpoints/template.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import type { RawAxiosRequestHeaders } from 'axios'
22
import type { AxiosInstance } from 'contentful-sdk-core'
33
import copy from 'fast-copy'
44
import type { SetOptional } from 'type-fest'
5-
import type {
6-
CursorPaginatedCollectionProp,
7-
GetSpaceEnvironmentParams,
8-
GetTemplateParams,
9-
} from '../../../common-types'
5+
import type { GetSpaceEnvironmentParams, GetTemplateParams } from '../../../common-types'
106
import type {
117
CreateTemplateProps,
128
TemplateProps,
139
TemplateQueryOptions,
1410
UpdateTemplateProps,
11+
TemplateCollection,
1512
} from '../../../entities/template'
1613
import type { RestEndpoint } from '../types'
1714
import * as raw from './raw'
@@ -24,7 +21,7 @@ export const getMany: RestEndpoint<'Template', 'getMany'> = (
2421
params: GetSpaceEnvironmentParams & { query: TemplateQueryOptions },
2522
headers?: RawAxiosRequestHeaders,
2623
) => {
27-
return raw.get<CursorPaginatedCollectionProp<TemplateProps>>(http, getBaseUrl(params), {
24+
return raw.get<TemplateCollection>(http, getBaseUrl(params), {
2825
params: params.query,
2926
headers,
3027
})

lib/common-types.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ import type {
168168
DataAssemblyProps,
169169
DataAssemblyQueryOptions,
170170
UpdateDataAssemblyProps,
171+
DataAssemblyCollection,
171172
} from './entities/data-assembly'
172173
import type {
173174
CreateEnvironmentTemplateProps,
@@ -423,6 +424,15 @@ export interface CursorPaginatedCollectionProp<TObj>
423424
}
424425
}
425426

427+
export interface ExoCursorPaginatedCollectionProp<TObj>
428+
extends CursorPaginatedCollectionProp<TObj> {
429+
total?: number
430+
pages: {
431+
next?: string
432+
prev?: string
433+
}
434+
}
435+
426436
export interface Collection<T, TPlain>
427437
extends CollectionProp<T>,
428438
DefaultElements<CollectionProp<TPlain>> {}
@@ -1676,7 +1686,7 @@ export type MRActions = {
16761686
ComponentType: {
16771687
getMany: {
16781688
params: GetSpaceEnvironmentParams & { query: ComponentTypeQueryOptions }
1679-
return: CursorPaginatedCollectionProp<ComponentTypeProps>
1689+
return: ExoCursorPaginatedCollectionProp<ComponentTypeProps>
16801690
}
16811691
get: {
16821692
params: GetComponentTypeParams
@@ -1822,11 +1832,11 @@ export type MRActions = {
18221832
DataAssembly: {
18231833
getMany: {
18241834
params: GetSpaceEnvironmentParams & { query: DataAssemblyQueryOptions }
1825-
return: CursorPaginatedCollectionProp<DataAssemblyProps>
1835+
return: DataAssemblyCollection
18261836
}
18271837
getManyPublished: {
18281838
params: GetSpaceEnvironmentParams & { query: DataAssemblyQueryOptions }
1829-
return: CursorPaginatedCollectionProp<DataAssemblyProps>
1839+
return: DataAssemblyCollection
18301840
}
18311841
getPublished: {
18321842
params: GetDataAssemblyParams
@@ -2662,7 +2672,7 @@ export type MRActions = {
26622672
Fragment: {
26632673
getMany: {
26642674
params: GetSpaceEnvironmentParams & { query: FragmentQueryOptions }
2665-
return: CursorPaginatedCollectionProp<FragmentProps>
2675+
return: ExoCursorPaginatedCollectionProp<FragmentProps>
26662676
}
26672677
get: {
26682678
params: GetFragmentParams
@@ -2694,7 +2704,7 @@ export type MRActions = {
26942704
Template: {
26952705
getMany: {
26962706
params: GetSpaceEnvironmentParams & { query: TemplateQueryOptions }
2697-
return: CursorPaginatedCollectionProp<TemplateProps>
2707+
return: ExoCursorPaginatedCollectionProp<TemplateProps>
26982708
}
26992709
get: {
27002710
params: GetTemplateParams
@@ -2769,7 +2779,7 @@ export type MRActions = {
27692779
Experience: {
27702780
getMany: {
27712781
params: GetSpaceEnvironmentParams & { query: ExperienceQueryOptions }
2772-
return: CursorPaginatedCollectionProp<ExperienceProps>
2782+
return: ExoCursorPaginatedCollectionProp<ExperienceProps>
27732783
}
27742784
get: {
27752785
params: GetExperienceParams

lib/entities/component-type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Except } from 'type-fest'
22
import type {
3-
CursorPaginatedCollectionProp,
43
CursorPaginationParams,
4+
ExoCursorPaginatedCollectionProp,
55
ExoMetadataProps,
66
Link,
77
} from '../common-types'
@@ -186,4 +186,4 @@ export type CreateComponentTypeProps = Except<ComponentTypeProps, 'sys'>
186186

187187
export type UpdateComponentTypeProps = ComponentTypeProps
188188

189-
export type ComponentTypeCollection = CursorPaginatedCollectionProp<ComponentTypeProps>
189+
export type ComponentTypeCollection = ExoCursorPaginatedCollectionProp<ComponentTypeProps>

lib/entities/data-assembly.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import type { CursorPaginationParams, Link, MetadataProps } from '../common-types'
1+
import type {
2+
CursorPaginationParams,
3+
ExoCursorPaginatedCollectionProp,
4+
Link,
5+
MetadataProps,
6+
} from '../common-types'
27
import { User } from './user'
38

49
export type DataAssemblyDataTypeField = {
@@ -98,3 +103,9 @@ export type UpdateDataAssemblyProps = DataAssemblyCommonProps & {
98103
export type DataAssemblyQueryOptions = CursorPaginationParams & {
99104
'sys.id[in]'?: string
100105
}
106+
107+
export type DataAssemblyCollection = ExoCursorPaginatedCollectionProp<DataAssemblyProps> & {
108+
errors?: {
109+
notFoundIds: string[]
110+
}
111+
}

lib/entities/experience.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {
2-
CursorPaginatedCollectionProp,
32
CursorPaginationParams,
3+
ExoCursorPaginatedCollectionProp,
44
ExperienceMetadataProps,
55
Link,
66
} from '../common-types'
@@ -94,4 +94,4 @@ export type InlineFragmentNode = {
9494
slots?: Record<string, Array<FragmentNode | InlineFragmentNode>>
9595
}
9696

97-
export type ExperienceCollection = CursorPaginatedCollectionProp<ExperienceProps>
97+
export type ExperienceCollection = ExoCursorPaginatedCollectionProp<ExperienceProps>

lib/entities/fragment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Except } from 'type-fest'
22
import type {
3-
CursorPaginatedCollectionProp,
43
CursorPaginationParams,
4+
ExoCursorPaginatedCollectionProp,
55
ExoMetadataProps,
66
Link,
77
} from '../common-types'
@@ -72,4 +72,4 @@ export type FragmentQueryOptions = CursorPaginationParams & {
7272
[key: string]: unknown
7373
}
7474

75-
export type FragmentCollection = CursorPaginatedCollectionProp<FragmentProps>
75+
export type FragmentCollection = ExoCursorPaginatedCollectionProp<FragmentProps>

0 commit comments

Comments
 (0)