@@ -5,30 +5,25 @@ import type { OpPatch } from 'json-patch'
55import type { SetOptional } from 'type-fest'
66import type {
77 CollectionProp ,
8- GetEntryParams ,
9- GetManyEntryParams ,
8+ CreateReleaseEntryParams ,
109 CreateWithIdReleaseEntryParams ,
10+ GetManyReleaseEntryParams ,
11+ GetReleaseEntryParams ,
1112 GetSpaceEnvironmentParams ,
1213 KeyValueMap ,
13- PatchEntryParams ,
1414 PatchReleaseEntryParams ,
1515 QueryParams ,
16- UpdateEntryParams ,
1716 UpdateReleaseEntryParams ,
18- CreateReleaseEntryParams ,
19- GetManyReleaseEntryParams ,
20- GetReleaseEntryParams ,
2117} from '../../../common-types'
2218import type { CreateEntryProps , EntryProps , EntryReferenceProps } from '../../../entities/entry'
2319import type { RestEndpoint } from '../types'
2420import * as raw from './raw'
25- import { createWithId as createWithIdReleaseEntry } from './release-entry'
26- import { normalizeSelect } from './utils'
2721import * as releaseEntry from './release-entry'
22+ import { normalizeSelect } from './utils'
2823
2924export const get : RestEndpoint < 'Entry' , 'get' > = < T extends KeyValueMap = KeyValueMap > (
3025 http : AxiosInstance ,
31- params : GetEntryParams & QueryParams & { releaseId ?: string } ,
26+ params : GetSpaceEnvironmentParams & { entryId : string ; releaseId ?: string } & QueryParams ,
3227 rawData ?: unknown ,
3328 headers ?: RawAxiosRequestHeaders
3429) => {
@@ -66,7 +61,7 @@ export const getPublished: RestEndpoint<'Entry', 'getPublished'> = <
6661
6762export const getMany : RestEndpoint < 'Entry' , 'getMany' > = < T extends KeyValueMap = KeyValueMap > (
6863 http : AxiosInstance ,
69- params : GetManyEntryParams & QueryParams & { releaseId ?: string } ,
64+ params : GetSpaceEnvironmentParams & QueryParams & { releaseId ?: string } ,
7065 rawData ?: unknown ,
7166 headers ?: RawAxiosRequestHeaders
7267) => {
@@ -86,7 +81,7 @@ export const getMany: RestEndpoint<'Entry', 'getMany'> = <T extends KeyValueMap
8681
8782export const patch : RestEndpoint < 'Entry' , 'patch' > = < T extends KeyValueMap = KeyValueMap > (
8883 http : AxiosInstance ,
89- params : PatchEntryParams & QueryParams ,
84+ params : GetSpaceEnvironmentParams & { entryId : string ; version : number ; releaseId ?: string } ,
9085 data : OpPatch [ ] ,
9186 headers ?: RawAxiosRequestHeaders
9287) => {
@@ -110,7 +105,7 @@ export const patch: RestEndpoint<'Entry', 'patch'> = <T extends KeyValueMap = Ke
110105
111106export const update : RestEndpoint < 'Entry' , 'update' > = < T extends KeyValueMap = KeyValueMap > (
112107 http : AxiosInstance ,
113- params : UpdateEntryParams & QueryParams ,
108+ params : GetSpaceEnvironmentParams & { entryId : string ; releaseId ?: string } ,
114109 rawData : EntryProps < T > ,
115110 headers ?: RawAxiosRequestHeaders
116111) => {
@@ -209,7 +204,7 @@ export const unarchive: RestEndpoint<'Entry', 'unarchive'> = <T extends KeyValue
209204
210205export const create : RestEndpoint < 'Entry' , 'create' > = < T extends KeyValueMap = KeyValueMap > (
211206 http : AxiosInstance ,
212- params : GetSpaceEnvironmentParams & { contentTypeId : string ; releaseId ?: string } & QueryParams ,
207+ params : GetSpaceEnvironmentParams & { contentTypeId : string ; releaseId ?: string } ,
213208 rawData : CreateEntryProps < T >
214209) => {
215210 if ( params . releaseId ) {
@@ -242,21 +237,20 @@ export const createWithId: RestEndpoint<'Entry', 'createWithId'> = <
242237 rawData : CreateEntryProps < T >
243238) => {
244239 if ( params . releaseId ) {
245- return createWithIdReleaseEntry ( http , params as CreateWithIdReleaseEntryParams , rawData , { } )
246- } else {
247- const data = copy ( rawData )
248-
249- return raw . put < EntryProps < T > > (
250- http ,
251- `/spaces/${ params . spaceId } /environments/${ params . environmentId } /entries/${ params . entryId } ` ,
252- data ,
253- {
254- headers : {
255- 'X-Contentful-Content-Type' : params . contentTypeId ,
256- } ,
257- }
258- )
240+ return releaseEntry . createWithId ( http , params as CreateWithIdReleaseEntryParams , rawData , { } )
259241 }
242+ const data = copy ( rawData )
243+
244+ return raw . put < EntryProps < T > > (
245+ http ,
246+ `/spaces/${ params . spaceId } /environments/${ params . environmentId } /entries/${ params . entryId } ` ,
247+ data ,
248+ {
249+ headers : {
250+ 'X-Contentful-Content-Type' : params . contentTypeId ,
251+ } ,
252+ }
253+ )
260254}
261255
262256export const references : RestEndpoint < 'Entry' , 'references' > = (
0 commit comments