From 38c21496ee6cd11f98dc67cc7ecd6f882dfaac4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Thu, 20 Nov 2025 15:53:08 +0100 Subject: [PATCH 1/2] refactor: include op-patch from json-patch to avoid including json-patch as regualr dependency for typescript projects --- lib/adapters/REST/endpoints/concept-scheme.ts | 2 +- lib/adapters/REST/endpoints/concept.ts | 2 +- lib/adapters/REST/endpoints/entry.ts | 2 +- lib/adapters/REST/endpoints/release-entry.ts | 2 +- lib/adapters/REST/make-request.ts | 3 +- lib/common-types.ts | 29 ++++++++++++++++++- lib/create-entry-api.ts | 3 +- lib/plain/common-types.ts | 2 +- lib/plain/entities/concept-scheme.ts | 2 +- lib/plain/entities/concept.ts | 2 +- package-lock.json | 9 ------ package.json | 2 -- 12 files changed, 37 insertions(+), 23 deletions(-) diff --git a/lib/adapters/REST/endpoints/concept-scheme.ts b/lib/adapters/REST/endpoints/concept-scheme.ts index 564ff76df6..8c5e87c50b 100644 --- a/lib/adapters/REST/endpoints/concept-scheme.ts +++ b/lib/adapters/REST/endpoints/concept-scheme.ts @@ -1,7 +1,7 @@ import type { RawAxiosRequestHeaders } from 'axios' import type { AxiosInstance } from 'contentful-sdk-core' -import type { OpPatch } from 'json-patch' import type { + OpPatch, CursorPaginatedCollectionProp, DeleteConceptSchemeParams, GetConceptSchemeParams, diff --git a/lib/adapters/REST/endpoints/concept.ts b/lib/adapters/REST/endpoints/concept.ts index 58c5532374..67c229113d 100644 --- a/lib/adapters/REST/endpoints/concept.ts +++ b/lib/adapters/REST/endpoints/concept.ts @@ -1,7 +1,7 @@ import type { RawAxiosRequestHeaders } from 'axios' import type { AxiosInstance } from 'contentful-sdk-core' -import type { OpPatch } from 'json-patch' import type { + OpPatch, CursorPaginatedCollectionProp, DeleteConceptParams, GetConceptDescendantsParams, diff --git a/lib/adapters/REST/endpoints/entry.ts b/lib/adapters/REST/endpoints/entry.ts index 5a1e41bf68..10a08af821 100644 --- a/lib/adapters/REST/endpoints/entry.ts +++ b/lib/adapters/REST/endpoints/entry.ts @@ -1,9 +1,9 @@ import type { RawAxiosRequestHeaders } from 'axios' import type { AxiosInstance } from 'contentful-sdk-core' import copy from 'fast-copy' -import type { OpPatch } from 'json-patch' import type { SetOptional } from 'type-fest' import type { + OpPatch, CollectionProp, CreateReleaseEntryParams, CreateWithIdReleaseEntryParams, diff --git a/lib/adapters/REST/endpoints/release-entry.ts b/lib/adapters/REST/endpoints/release-entry.ts index 6ea784a9fb..2df59fa186 100644 --- a/lib/adapters/REST/endpoints/release-entry.ts +++ b/lib/adapters/REST/endpoints/release-entry.ts @@ -1,9 +1,9 @@ import type { RawAxiosRequestHeaders } from 'axios' import type { AxiosInstance } from 'contentful-sdk-core' import copy from 'fast-copy' -import type { OpPatch } from 'json-patch' import type { SetOptional } from 'type-fest' import type { + OpPatch, CollectionProp, CreateReleaseEntryParams, CreateWithIdReleaseEntryParams, diff --git a/lib/adapters/REST/make-request.ts b/lib/adapters/REST/make-request.ts index 6e6d599ed1..399fd6facd 100644 --- a/lib/adapters/REST/make-request.ts +++ b/lib/adapters/REST/make-request.ts @@ -1,6 +1,5 @@ import type { AxiosInstance } from 'contentful-sdk-core' -import type { MakeRequestOptions, MakeRequestPayload } from '../../common-types' -import type { OpPatch } from 'json-patch' +import type { OpPatch, MakeRequestOptions, MakeRequestPayload } from '../../common-types' import type { RawAxiosRequestHeaders } from 'axios' import endpoints from './endpoints' diff --git a/lib/common-types.ts b/lib/common-types.ts index 76b6b96261..f51073e260 100644 --- a/lib/common-types.ts +++ b/lib/common-types.ts @@ -1,5 +1,4 @@ import type { RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios' -import type { OpPatch } from 'json-patch' import type { Stream } from 'stream' import type { AccessTokenProps, @@ -910,6 +909,34 @@ export interface Adapter { makeRequest: MakeRequestWithUserAgent } +export type OpPatch = AddPatch | RemovePatch | ReplacePatch | MovePatch | CopyPatch | TestPatch +interface Patch { + path: string +} +interface AddPatch extends Patch { + op: 'add' + value: any +} +interface RemovePatch extends Patch { + op: 'remove' +} +interface ReplacePatch extends Patch { + op: 'replace' + value: any +} +interface MovePatch extends Patch { + op: 'move' + from: string +} +interface CopyPatch extends Patch { + op: 'copy' + from: string +} +interface TestPatch extends Patch { + op: 'test' + value: any +} + /** * @private */ diff --git a/lib/create-entry-api.ts b/lib/create-entry-api.ts index bbc3f8cbe1..fadff56360 100644 --- a/lib/create-entry-api.ts +++ b/lib/create-entry-api.ts @@ -1,5 +1,4 @@ -import type { OpPatch } from 'json-patch' -import type { MakeRequest } from './common-types' +import type { MakeRequest, OpPatch } from './common-types' import type { CreateCommentParams, CreateCommentProps } from './entities/comment' import type { Entry, EntryProps, EntryReferenceOptionsProps } from './entities/entry' import type { CreateTaskProps } from './entities/task' diff --git a/lib/plain/common-types.ts b/lib/plain/common-types.ts index 1a98cf55d5..817e2d80cd 100644 --- a/lib/plain/common-types.ts +++ b/lib/plain/common-types.ts @@ -1,6 +1,6 @@ import type { RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios' -import type { OpPatch } from 'json-patch' import type { + OpPatch, BasicCursorPaginationOptions, CollectionProp, CreateReleaseAssetParams, diff --git a/lib/plain/entities/concept-scheme.ts b/lib/plain/entities/concept-scheme.ts index 57b36903ea..597fa225cb 100644 --- a/lib/plain/entities/concept-scheme.ts +++ b/lib/plain/entities/concept-scheme.ts @@ -1,4 +1,5 @@ import type { + OpPatch, CursorPaginatedCollectionProp, DeleteConceptSchemeParams, GetConceptSchemeParams, @@ -7,7 +8,6 @@ import type { UpdateConceptSchemeParams, } from '../../common-types' import type { ConceptSchemeProps, CreateConceptSchemeProps } from '../../entities/concept-scheme' -import type { OpPatch } from 'json-patch' import type { SetOptional } from 'type-fest' export type ConceptSchemePlainClientAPI = { diff --git a/lib/plain/entities/concept.ts b/lib/plain/entities/concept.ts index 5e2825c23f..e96eec4f0a 100644 --- a/lib/plain/entities/concept.ts +++ b/lib/plain/entities/concept.ts @@ -1,4 +1,5 @@ import type { + OpPatch, CursorPaginatedCollectionProp, DeleteConceptParams, GetConceptDescendantsParams, @@ -8,7 +9,6 @@ import type { UpdateConceptParams, } from '../../common-types' import type { ConceptProps, CreateConceptProps } from '../../entities/concept' -import type { OpPatch } from 'json-patch' import type { SetOptional } from 'type-fest' export type ConceptPlainClientAPI = { diff --git a/package-lock.json b/package-lock.json index 7e468604e0..db519f9dc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,6 @@ "@rollup/plugin-typescript": "^12.3.0", "@semantic-release/changelog": "^6.0.3", "@size-limit/file": "^11.1.6", - "@types/json-patch": "0.0.30", "@types/lodash": "^4.14.168", "@types/node": "^20.12.13", "@vitest/browser": "^2.1.5", @@ -50,7 +49,6 @@ "express": "^4.21.1", "husky": "^9.1.7", "in-publish": "^2.0.1", - "json-patch": "^0.7.0", "jsonwebtoken": "^9.0.2", "lint-staged": "^15.2.5", "lodash": "^4.17.20", @@ -10609,13 +10607,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-patch": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/json-patch/-/json-patch-0.7.0.tgz", - "integrity": "sha512-9zaGTzsV6Hal5HVMC8kb4niXYQOOcq3tUp0P/GTw6HHZFPVwtCU2+mXE9q59MelL9uknALWnoKrUxnDpUX728g==", - "dev": true, - "license": "BSD" - }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", diff --git a/package.json b/package.json index 8adfea5242..e6273b510e 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,6 @@ "@rollup/plugin-typescript": "^12.3.0", "@semantic-release/changelog": "^6.0.3", "@size-limit/file": "^11.1.6", - "@types/json-patch": "0.0.30", "@types/lodash": "^4.14.168", "@types/node": "^20.12.13", "@vitest/browser": "^2.1.5", @@ -111,7 +110,6 @@ "express": "^4.21.1", "husky": "^9.1.7", "in-publish": "^2.0.1", - "json-patch": "^0.7.0", "jsonwebtoken": "^9.0.2", "lint-staged": "^15.2.5", "lodash": "^4.17.20", From 39d2509458a8a22841e519b88a475e3f55951902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Fri, 28 Nov 2025 13:00:20 +0100 Subject: [PATCH 2/2] Remove unused Stream import from common-types.ts --- lib/common-types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/common-types.ts b/lib/common-types.ts index 7394307cc6..f30b7e230f 100644 --- a/lib/common-types.ts +++ b/lib/common-types.ts @@ -1,5 +1,4 @@ import type { RawAxiosRequestConfig, RawAxiosRequestHeaders } from 'axios' -import type { Stream } from 'stream' import type { OpPatch } from 'json-patch' import type { AccessTokenProps,