diff --git a/lib/types/index.ts b/lib/types/index.ts index 3d282daa0e..1fc0d6e690 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -69,7 +69,7 @@ export type { ContentEntityType, Items, Link, - WithOptionalSys, + WithOptionalId, } from './utils' export type { WindowAPI } from './window.types' diff --git a/lib/types/space.types.ts b/lib/types/space.types.ts index 1efe8e9c00..1590e86cb4 100644 --- a/lib/types/space.types.ts +++ b/lib/types/space.types.ts @@ -10,7 +10,14 @@ import { User, TagVisibility, } from './entities' -import { CollectionResponse, ContentEntityType, Link, WithOptionalSys, SearchQuery } from './utils' +import { + CollectionResponse, + ContentEntityType, + Link, + WithOptionalId, + SearchQuery, + WithId, +} from './utils' type Snapshot = { sys: { @@ -33,7 +40,7 @@ export interface SpaceAPI { getCachedContentTypes: () => ContentType[] getContentType: (id: string) => Promise getContentTypes: () => Promise> - createContentType: (data: ContentType) => Promise + createContentType: (data: WithId) => Promise updateContentType: (data: ContentType) => Promise deleteContentType: (data: ContentType) => Promise @@ -44,7 +51,7 @@ export interface SpaceAPI { ) => Promise>> createEntry: ( contentTypeId: string, - data: WithOptionalSys> + data: WithOptionalId> ) => Promise> updateEntry: (data: Entry) => Promise> publishEntry: (data: Entry) => Promise> @@ -60,7 +67,7 @@ export interface SpaceAPI { getAssets: ( query?: Query ) => Promise> - createAsset: (data: WithOptionalSys) => Promise + createAsset: (data: WithOptionalId) => Promise updateAsset: (data: Asset) => Promise deleteAsset: (data: Asset) => Promise publishAsset: (data: Asset) => Promise diff --git a/lib/types/utils.ts b/lib/types/utils.ts index 1451584b67..1a04b34444 100644 --- a/lib/types/utils.ts +++ b/lib/types/utils.ts @@ -1,5 +1,13 @@ -export type WithOptionalSys = Omit & { - sys?: Type['sys'] +type SysWithId = { + id: string +} + +export type WithOptionalId = Omit & { + sys?: Partial & SysWithId> +} + +export type WithId = Omit & { + sys: Partial> & SysWithId } export interface Link {