Skip to content

Commit 4eabbbf

Browse files
feat: align taxonomy update methods with standard [NONE] (#2478)
1 parent 2bebbd2 commit 4eabbbf

File tree

9 files changed

+10
-208
lines changed

9 files changed

+10
-208
lines changed

lib/adapters/REST/endpoints/concept-scheme.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,6 @@ export const patch: RestEndpoint<'ConceptScheme', 'patch'> = (
9191
}
9292

9393
export const update: RestEndpoint<'ConceptScheme', 'update'> = (
94-
http: AxiosInstance,
95-
params: UpdateConceptSchemeParams,
96-
data: OpPatch[],
97-
headers?: RawAxiosRequestHeaders
98-
) => {
99-
return raw.patch<ConceptSchemeProps>(
100-
http,
101-
`${basePath(params.organizationId)}/${params.conceptSchemeId}`,
102-
data,
103-
{
104-
headers: {
105-
'X-Contentful-Version': params.version,
106-
'Content-Type': 'application/json-patch+json',
107-
...headers,
108-
},
109-
}
110-
)
111-
}
112-
113-
export const updatePut: RestEndpoint<'ConceptScheme', 'updatePut'> = (
11494
http: AxiosInstance,
11595
params: UpdateConceptSchemeParams,
11696
data: CreateConceptSchemeProps,

lib/adapters/REST/endpoints/concept.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,6 @@ export const patch: RestEndpoint<'Concept', 'patch'> = (
5555
}
5656

5757
export const update: RestEndpoint<'Concept', 'update'> = (
58-
http: AxiosInstance,
59-
params: UpdateConceptParams,
60-
data: OpPatch[],
61-
headers?: RawAxiosRequestHeaders
62-
) => {
63-
return raw.patch<ConceptProps>(
64-
http,
65-
`${basePath(params.organizationId)}/${params.conceptId}`,
66-
data,
67-
{
68-
headers: {
69-
'X-Contentful-Version': params.version,
70-
'Content-Type': 'application/json-patch+json',
71-
...headers,
72-
},
73-
}
74-
)
75-
}
76-
77-
export const updatePut: RestEndpoint<'Concept', 'updatePut'> = (
7858
http: AxiosInstance,
7959
params: UpdateConceptParams,
8060
data: CreateConceptProps,

lib/common-types.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ type MRInternal<UA extends boolean> = {
524524
(opts: MROpts<'Concept', 'createWithId', UA>): MRReturn<'Concept', 'createWithId'>
525525
(opts: MROpts<'Concept', 'patch', UA>): MRReturn<'Concept', 'patch'>
526526
(opts: MROpts<'Concept', 'update', UA>): MRReturn<'Concept', 'update'>
527-
(opts: MROpts<'Concept', 'updatePut', UA>): MRReturn<'Concept', 'updatePut'>
528527
(opts: MROpts<'Concept', 'delete', UA>): MRReturn<'Concept', 'delete'>
529528

530529
(opts: MROpts<'ConceptScheme', 'get', UA>): MRReturn<'ConceptScheme', 'get'>
@@ -534,7 +533,6 @@ type MRInternal<UA extends boolean> = {
534533
(opts: MROpts<'ConceptScheme', 'createWithId', UA>): MRReturn<'ConceptScheme', 'createWithId'>
535534
(opts: MROpts<'ConceptScheme', 'patch', UA>): MRReturn<'ConceptScheme', 'patch'>
536535
(opts: MROpts<'ConceptScheme', 'update', UA>): MRReturn<'ConceptScheme', 'update'>
537-
(opts: MROpts<'ConceptScheme', 'updatePut', UA>): MRReturn<'ConceptScheme', 'updatePut'>
538536
(opts: MROpts<'ConceptScheme', 'delete', UA>): MRReturn<'ConceptScheme', 'delete'>
539537

540538
(opts: MROpts<'ContentType', 'get', UA>): MRReturn<'ContentType', 'get'>
@@ -1334,11 +1332,6 @@ export type MRActions = {
13341332
return: ConceptProps
13351333
}
13361334
update: {
1337-
params: UpdateConceptParams
1338-
payload: OpPatch[]
1339-
return: ConceptProps
1340-
}
1341-
updatePut: {
13421335
params: UpdateConceptParams
13431336
payload: CreateConceptProps
13441337
return: ConceptProps
@@ -1385,11 +1378,6 @@ export type MRActions = {
13851378
return: ConceptSchemeProps
13861379
}
13871380
update: {
1388-
params: UpdateConceptSchemeParams
1389-
payload: OpPatch[]
1390-
return: ConceptSchemeProps
1391-
}
1392-
updatePut: {
13931381
params: UpdateConceptSchemeParams
13941382
payload: CreateConceptSchemeProps
13951383
return: ConceptSchemeProps

lib/plain/entities/concept-scheme.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,48 +46,27 @@ export type ConceptSchemePlainClientAPI = {
4646
payload: CreateConceptSchemeProps
4747
): Promise<ConceptSchemeProps>
4848

49-
/**
50-
* Update Concept Scheme
51-
* @returns the updated Concept Scheme
52-
* @throws if the request fails
53-
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept-scheme}
54-
* @deprecated The behavior of this method as a PATCH is being deprecated, and will be replaced with a PUT in the next major version. Use the `patch` method instead.
55-
* @example
56-
* ```javascript
57-
* const updatedConcept = await client.conceptScheme.update({
58-
* organizationId: '<organization_id>',
59-
* conceptSchemeId: '<concept_scheme_id>',
60-
* version: 1,
61-
* }, conceptSchemePatch);
62-
* ```
63-
*/
64-
update(
65-
params: SetOptional<UpdateConceptSchemeParams, 'organizationId'>,
66-
payload: OpPatch[]
67-
): Promise<ConceptSchemeProps>
68-
6949
/**
7050
* Update Concept Scheme with PUT
7151
* @returns the updated Concept Scheme
7252
* @throws if the request fails
7353
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept-scheme}
74-
* @deprecated In the next major version, this method will be replaced with the standard `update` method which will be updated to use PUT instead of PATCH.
7554
* @example
7655
* ```javascript
7756
* const updatedConcept = await client.conceptScheme.update({
7857
* organizationId: '<organization_id>',
7958
* conceptSchemeId: '<concept_scheme_id>',
8059
* version: 1,
81-
* }, CreateConceptSchemeProps);
60+
* }, conceptSchemeProps);
8261
* ```
8362
*/
84-
updatePut(
63+
update(
8564
params: SetOptional<UpdateConceptSchemeParams, 'organizationId'>,
8665
payload: CreateConceptSchemeProps
8766
): Promise<ConceptSchemeProps>
8867

8968
/**
90-
* Update Concept Scheme
69+
* Update Concept Scheme with PATCH
9170
* @returns the updated Concept Scheme
9271
* @throws if the request fails
9372
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept-scheme}

lib/plain/entities/concept.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,47 +48,26 @@ export type ConceptPlainClientAPI = {
4848
): Promise<ConceptProps>
4949

5050
/**
51-
* Update Concept
51+
* Update Concept with PUT
5252
* @returns the updated Concept
5353
* @throws if the request fails
5454
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept}
55-
* @deprecated The behavior of this method as a PATCH is being deprecated, and will be replaced with a PUT in the next major version. Use the `patch` method instead.
5655
* @example
5756
* ```javascript
5857
* const updatedConcept = await client.concept.update({
5958
* organizationId: '<organization_id>',
6059
* conceptId: '<concept_id>',
6160
* version: 1,
62-
* }, patch);
61+
* }, conceptProps);
6362
* ```
6463
*/
6564
update(
66-
params: SetOptional<UpdateConceptParams, 'organizationId'>,
67-
payload: OpPatch[]
68-
): Promise<ConceptProps>
69-
70-
/**
71-
* Update Concept with PUT
72-
* @returns the updated Concept
73-
* @throws if the request fails
74-
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept}
75-
* @deprecated In the next major version, this method will be replaced with the standard `update` method which will be updated to use PUT instead of PATCH.
76-
* @example
77-
* ```javascript
78-
* const updatedConcept = await client.concept.updatePut({
79-
* organizationId: '<organization_id>',
80-
* conceptId: '<concept_id>',
81-
* version: 1,
82-
* }, patch);
83-
* ```
84-
*/
85-
updatePut(
8665
params: SetOptional<UpdateConceptParams, 'organizationId'>,
8766
payload: CreateConceptProps
8867
): Promise<ConceptProps>
8968

9069
/**
91-
* Update Concept
70+
* Update Concept with PATCH
9271
* @returns the updated Concept
9372
* @throws if the request fails
9473
* @see {@link https://www.contentful.com/developers/docs/references/content-management-api/#/reference/taxonomy/concept}

lib/plain/plain-client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export const createPlainClient = (
125125
delete: wrap(wrapParams, 'Concept', 'delete'),
126126
patch: wrap(wrapParams, 'Concept', 'patch'),
127127
update: wrap(wrapParams, 'Concept', 'update'),
128-
updatePut: wrap(wrapParams, 'Concept', 'updatePut'),
129128
getMany: wrap(wrapParams, 'Concept', 'getMany'),
130129
getDescendants: wrap(wrapParams, 'Concept', 'getDescendants'),
131130
getAncestors: wrap(wrapParams, 'Concept', 'getAncestors'),
@@ -140,7 +139,6 @@ export const createPlainClient = (
140139
createWithId: wrap(wrapParams, 'ConceptScheme', 'createWithId'),
141140
patch: wrap(wrapParams, 'ConceptScheme', 'patch'),
142141
update: wrap(wrapParams, 'ConceptScheme', 'update'),
143-
updatePut: wrap(wrapParams, 'ConceptScheme', 'updatePut'),
144142
},
145143
function: {
146144
get: wrap(wrapParams, 'Function', 'get'),

test/integration/taxonomy-integration.test.ts

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,6 @@ describe('Taxonomy Integration', () => {
126126
expect(result.scopeNote['en-US']).toEqual('Scope Note')
127127
})
128128

129-
it('creates and updates a concept', async () => {
130-
const concept: CreateConceptProps = {
131-
prefLabel: {
132-
'en-US': 'Test Concept',
133-
},
134-
}
135-
const result = await client.concept.create({}, concept)
136-
isConceptProps(result)
137-
expect(result.prefLabel['en-US']).toBe('Test Concept')
138-
expect(result.uri).toBeNull()
139-
conceptsToDelete.push(result)
140-
141-
const updatedConcept = await client.concept.update(
142-
{
143-
version: result.sys.version,
144-
conceptId: result.sys.id,
145-
},
146-
[
147-
{
148-
path: '/uri',
149-
op: 'replace',
150-
value: 'https://example.com/concept',
151-
},
152-
]
153-
)
154-
155-
isConceptProps(updatedConcept)
156-
expect(updatedConcept.uri).toBe('https://example.com/concept')
157-
})
158-
159129
it('create and update a concept - patch', async () => {
160130
const concept: CreateConceptProps = {
161131
prefLabel: {
@@ -198,7 +168,7 @@ describe('Taxonomy Integration', () => {
198168
expect(result.uri).to.null
199169
conceptsToDelete.push(result)
200170

201-
const updatedConcept = await client.concept.updatePut(
171+
const updatedConcept = await client.concept.update(
202172
{
203173
version: result.sys.version,
204174
conceptId: result.sys.id,
@@ -406,36 +376,6 @@ describe('Taxonomy Integration', () => {
406376
expect(result.definition['en-US']).toBe('Definition')
407377
})
408378

409-
it('creates and updates a concept scheme', async () => {
410-
const conceptScheme: CreateConceptSchemeProps = {
411-
prefLabel: {
412-
'en-US': 'Test ConceptScheme',
413-
},
414-
}
415-
const result = await client.conceptScheme.create({}, conceptScheme)
416-
isConceptSchemeProps(result)
417-
expect(result.prefLabel['en-US']).toBe('Test ConceptScheme')
418-
expect(result.uri).toBeNull()
419-
conceptSchemesToDelete.push(result)
420-
421-
const updatedConceptScheme = await client.conceptScheme.update(
422-
{
423-
version: result.sys.version,
424-
conceptSchemeId: result.sys.id,
425-
},
426-
[
427-
{
428-
path: '/uri',
429-
op: 'replace',
430-
value: 'https://example.com/updatedConceptScheme',
431-
},
432-
]
433-
)
434-
435-
isConceptSchemeProps(updatedConceptScheme)
436-
expect(updatedConceptScheme.uri).toBe('https://example.com/updatedConceptScheme')
437-
})
438-
439379
it('create and update a conceptScheme - patch', async () => {
440380
const conceptScheme: CreateConceptSchemeProps = {
441381
prefLabel: {
@@ -478,7 +418,7 @@ describe('Taxonomy Integration', () => {
478418
expect(result.uri).to.null
479419
conceptSchemesToDelete.push(result)
480420

481-
const updatedConceptScheme = await client.conceptScheme.updatePut(
421+
const updatedConceptScheme = await client.conceptScheme.update(
482422
{
483423
version: result.sys.version,
484424
conceptSchemeId: result.sys.id,

test/unit/adapters/REST/endpoints/concept-scheme.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,34 +119,13 @@ describe('ConceptScheme', () => {
119119
})
120120

121121
test('update', async () => {
122-
const { httpMock, adapterMock, entityMock } = setup(Promise.resolve({}))
123-
httpMock.patch.mockReturnValue(Promise.resolve({ data: entityMock }))
124-
125-
return adapterMock
126-
.makeRequest({
127-
entityType: 'ConceptScheme',
128-
action: 'update',
129-
userAgent: 'mocked',
130-
params: {
131-
organizationId: 'organization-id',
132-
conceptSchemeId: 'concept-scheme-id',
133-
},
134-
})
135-
.then(() => {
136-
expect(httpMock.patch.mock.calls[0][0]).to.eql(
137-
'/organizations/organization-id/taxonomy/concept-schemes/concept-scheme-id'
138-
)
139-
})
140-
})
141-
142-
test('updatePut', async () => {
143122
const { httpMock, adapterMock, entityMock } = setup(Promise.resolve({}))
144123
httpMock.put.mockReturnValue(Promise.resolve({ data: entityMock }))
145124

146125
return adapterMock
147126
.makeRequest({
148127
entityType: 'ConceptScheme',
149-
action: 'updatePut',
128+
action: 'update',
150129
params: {
151130
organizationId: 'organization-id',
152131
conceptSchemeId: 'concept-scheme-id',

test/unit/adapters/REST/endpoints/concept.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,33 +171,12 @@ describe('Concept', () => {
171171
test('update', async () => {
172172
const { httpMock, adapterMock, entityMock } = setup(Promise.resolve({}))
173173

174-
httpMock.patch.mockReturnValue(Promise.resolve({ data: entityMock }))
175-
176-
return adapterMock
177-
.makeRequest({
178-
entityType: 'Concept',
179-
action: 'update',
180-
userAgent: 'mocked',
181-
params: {
182-
organizationId: 'organization-id',
183-
conceptId: 'concept-id',
184-
},
185-
})
186-
.then(() => {
187-
expect(httpMock.patch.mock.calls[0][0]).to.eql(
188-
'/organizations/organization-id/taxonomy/concepts/concept-id'
189-
)
190-
})
191-
})
192-
test('updatePut', async () => {
193-
const { httpMock, adapterMock, entityMock } = setup(Promise.resolve({}))
194-
195174
httpMock.put.mockReturnValue(Promise.resolve({ data: entityMock }))
196175

197176
return adapterMock
198177
.makeRequest({
199178
entityType: 'Concept',
200-
action: 'updatePut',
179+
action: 'update',
201180
params: {
202181
organizationId: 'organization-id',
203182
conceptId: 'concept-id',

0 commit comments

Comments
 (0)