Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/adapters/REST/endpoints/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const createWithId: RestEndpoint<'Asset', 'createWithId'> = (
export const createFromFiles: RestEndpoint<'Asset', 'createFromFiles'> = async (
http: AxiosInstance,
params: GetSpaceEnvironmentParams & { uploadTimeout?: number; releaseId?: string },
data: Omit<AssetFileProp, 'sys'>,
data: AssetFileProp
) => {
if (params.releaseId) {
return releaseAsset.createFromFiles(http, params as CreateWithFilesReleaseAssetParams, data, {})
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/REST/endpoints/release-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const createWithId: RestEndpoint<'ReleaseAsset', 'createWithId'> = (
export const createFromFiles: RestEndpoint<'ReleaseAsset', 'createFromFiles'> = async (
http: AxiosInstance,
params: CreateWithFilesReleaseAssetParams,
data: Omit<AssetFileProp, 'sys'>,
data: AssetFileProp,
) => {
const httpUpload = getUploadHttpClient(http, { uploadTimeout: params.uploadTimeout })

Expand Down
81 changes: 33 additions & 48 deletions lib/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,41 +254,41 @@ export interface SpaceQueryOptions extends PaginationQueryOptions {
spaceId?: string
}

export interface BasicMetaSysProps {
export interface BasicMetaSysProps<TSubject extends string = string> {
type: string
id: string
version: number
createdBy?: SysLink
createdBy?: { [Subject in TSubject]: Link<Subject> }[TSubject]
createdAt: string
updatedBy?: SysLink
updatedBy?: { [Subject in TSubject]: Link<Subject> }[TSubject]
updatedAt: string
}

export interface MetaSysProps extends BasicMetaSysProps {
space?: SysLink
export interface MetaSysProps<TSubject extends string = string>
extends BasicMetaSysProps<TSubject> {
space?: Link<'Space'>
/**
* @deprecated `status` only exists on entities. Please refactor to use a
* type guard to get the correct `EntityMetaSysProps` type with this property.
*/
status?: SysLink
status?: Link<'Status'>
publishedVersion?: number
archivedVersion?: number
archivedBy?: SysLink
archivedBy?: { [Subject in TSubject]: Link<Subject> }[TSubject]
archivedAt?: string
deletedVersion?: number
deletedBy?: SysLink
deletedBy?: { [Subject in TSubject]: Link<Subject> }[TSubject]
deletedAt?: string
}

export interface EntityMetaSysProps extends MetaSysProps {
export interface EntityMetaSysProps extends MetaSysProps<'User' | 'AppDefinition'> {
/**
* @deprecated `contentType` only exists on entries. Please refactor to use a
* type guard to get the correct `EntryMetaSysProps` type with this property.
*/
contentType: SysLink
space: SysLink
status?: SysLink
environment: SysLink
contentType: Link<'ContentType'>
space: Link<'Space'>
environment: Link<'Environment'>
publishedBy?: Link<'User'> | Link<'AppDefinition'>
publishedAt?: string
firstPublishedAt?: string
Expand All @@ -298,26 +298,11 @@ export interface EntityMetaSysProps extends MetaSysProps {
release?: Link<'Release'>
}

export interface EntryMetaSysProps extends EntityMetaSysProps {
contentType: SysLink
automationTags: Link<'Tag'>[]
}

export interface MetaLinkProps {
type: string
linkType: string
id: string
}

export interface MetadataProps {
tags: Link<'Tag'>[]
concepts?: Link<'TaxonomyConcept'>[]
}

export interface SysLink {
sys: MetaLinkProps
}

export interface CollectionProp<TObj> {
sys: {
type: 'Array'
Expand All @@ -338,11 +323,11 @@ export interface CursorPaginatedCollectionProp<TObj>

export interface Collection<T, TPlain>
extends CollectionProp<T>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: is this just a whitespace change?

  • confirm

DefaultElements<CollectionProp<TPlain>> {}
DefaultElements<CollectionProp<TPlain>> {}

export interface CursorPaginatedCollection<T, TPlain>
extends CursorPaginatedCollectionProp<T>,
DefaultElements<CursorPaginatedCollectionProp<TPlain>> {}
DefaultElements<CursorPaginatedCollectionProp<TPlain>> {}

/* eslint-disable @typescript-eslint/no-explicit-any */
export interface QueryOptions extends BasicQueryOptions {
Expand Down Expand Up @@ -1266,7 +1251,7 @@ export type MRActions = {
}
createFromFiles: {
params: GetSpaceEnvironmentParams & { uploadTimeout?: number; releaseId?: string }
payload: Omit<AssetFileProp, 'sys'>
payload: AssetFileProp
return: AssetProps
}
processForAllLocales: {
Expand Down Expand Up @@ -1342,44 +1327,44 @@ export type MRActions = {
| {
params: GetManyCommentsParams & PlainTextBodyFormat & QueryParams
return: CollectionProp<CommentProps>
}
}
| {
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
getAll:
| {
params: GetManyCommentsParams & QueryParams & PlainTextBodyFormat
return: CollectionProp<CommentProps>
}
}
| {
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
}
create:
| {
params: CreateCommentParams & PlainTextBodyFormat
payload: CreateCommentProps
return: CommentProps
}
}
| {
params: CreateCommentParams & RichTextBodyFormat
payload: RichTextCommentBodyPayload
return: RichTextCommentProps
}
params: CreateCommentParams & RichTextBodyFormat
payload: RichTextCommentBodyPayload
return: RichTextCommentProps
}
update:
| {
params: UpdateCommentParams
payload: UpdateCommentProps
headers?: RawAxiosRequestHeaders
return: CommentProps
}
}
| {
params: UpdateCommentParams
payload: Omit<UpdateCommentProps, 'body'> & RichTextCommentBodyPayload
headers?: RawAxiosRequestHeaders
return: RichTextCommentProps
}
}
delete: { params: DeleteCommentParams; return: void }
}
Concept: {
Expand Down Expand Up @@ -1635,9 +1620,9 @@ export type MRActions = {
}
getForEnvironment: {
params: BasicCursorPaginationOptions &
EnvironmentTemplateParams & {
installationId?: string
}
EnvironmentTemplateParams & {
installationId?: string
}
return: CursorPaginatedCollectionProp<EnvironmentTemplateInstallationProps>
}
}
Expand Down Expand Up @@ -1934,7 +1919,7 @@ export type MRActions = {
}
createFromFiles: {
params: CreateWithFilesReleaseAssetParams & QueryParams
payload: Omit<AssetFileProp, 'sys'>
payload: AssetFileProp,
headers?: RawAxiosRequestHeaders
return: AssetProps<{ release: Link<'Release'> }>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/create-environment-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ export default function createEnvironmentApi(makeRequest: MakeRequest) {
* .catch(console.error)
* ```
*/
createAssetFromFiles(data: Omit<AssetFileProp, 'sys'>, options?: CreateAssetFromFilesOptions) {
createAssetFromFiles(data: AssetFileProp, options?: CreateAssetFromFilesOptions) {
const raw = this.toPlainObject() as EnvironmentProps
return makeRequest({
entityType: 'Asset',
Expand Down
6 changes: 3 additions & 3 deletions lib/entities/access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import copy from 'fast-copy'
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import enhanceWithMethods from '../enhance-with-methods'
import { wrapCollection } from '../common-utils'
import type { DefaultElements, MakeRequest, BasicMetaSysProps, SysLink } from '../common-types'
import type { DefaultElements, MakeRequest, BasicMetaSysProps, Link } from '../common-types'

type Application = {
id?: string
name?: string
sys: SysLink
sys: Link<'Application'>
}

type AccessTokenSysProps = BasicMetaSysProps & {
type AccessTokenSysProps = BasicMetaSysProps<'User'> & {
application: Application | null
expiresAt: string | null
lastUsedAt: string | null
Expand Down
8 changes: 4 additions & 4 deletions lib/entities/ai-action-invocation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import copy from 'fast-copy'
import type { DefaultElements, MakeRequest, SysLink } from '../common-types'
import type { DefaultElements, Link, MakeRequest } from '../common-types'
import { wrapCollection } from '../common-utils'
import type { Document as RichTextDocument } from '@contentful/rich-text-types'

Expand Down Expand Up @@ -40,9 +40,9 @@ export type AiActionInvocationProps = {
sys: {
id: string
type: 'AiActionInvocation'
space: SysLink
environment: SysLink
aiAction: SysLink
space: Link<'Space'>
environment: Link<'Environment'>
aiAction: Link<'AiAction'>
status: InvocationStatus
errorCode?: string
}
Expand Down
10 changes: 2 additions & 8 deletions lib/entities/ai-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ export interface AiActionQueryOptions {
}

export type AiActionProps = {
sys: MetaSysProps & {
sys: MetaSysProps<'User' | 'AppDefinition'> & {
type: 'AiAction'
space: { sys: { id: string } }
space: Link<'Space'>
publishedBy?: Link<'User'> | Link<'AppDefinition'>
updatedBy: Link<'User'> | Link<'AppDefinition'>
createdBy: Link<'User'> | Link<'AppDefinition'>
publishedVersion?: number
version: number
publishedAt?: string
updatedAt: string
createdAt: string
id: string
}
name: string
description: string
Expand Down
10 changes: 4 additions & 6 deletions lib/entities/api-key.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import copy from 'fast-copy'
import type { DefaultElements, MakeRequest, MetaLinkProps, MetaSysProps } from '../common-types'
import type { DefaultElements, Link, MakeRequest, MetaSysProps } from '../common-types'
import { wrapCollection } from '../common-utils'
import enhanceWithMethods from '../enhance-with-methods'

export type ApiKeyProps = {
sys: MetaSysProps
sys: MetaSysProps<'User'>
name: string
accessToken: string
environments: {
sys: MetaLinkProps
}[]
preview_api_key: { sys: MetaLinkProps }
environments: Link<'Environment'>[]
preview_api_key: Link<'PreviewApiKey'>
description?: string
policies?: { effect: string; action: string }[]
}
Expand Down
10 changes: 5 additions & 5 deletions lib/entities/app-access-token.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import copy from 'fast-copy'
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'

type AppAccessTokenSys = Except<BasicMetaSysProps, 'version' | 'id'> & {
space: SysLink
environment: SysLink
appDefinition: SysLink
type AppAccessTokenSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
space: Link<'Space'>
environment: Link<'Environment'>
appDefinition: Link<'AppDefinition'>
expiresAt: string
}

Expand Down
15 changes: 8 additions & 7 deletions lib/entities/app-action-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
BasicMetaSysProps,
AppActionCallRetryOptions,
DefaultElements,
Link,
MakeRequest,
SysLink,
CreateWithResponseParams,
Expand All @@ -15,11 +16,11 @@ import type {
import type { WebhookCallDetailsProps } from './webhook'
import enhanceWithMethods from '../enhance-with-methods'

type AppActionCallSys = Except<BasicMetaSysProps, 'version'> & {
appDefinition: SysLink
space: SysLink
environment: SysLink
action: SysLink
type AppActionCallSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
space: Link<'Space'>
environment: Link<'Environment'>
action: Link<'AppAction'>
appActionCallResponse?: SysLink
} & (AppActionCallSucceeded | AppActionCallProcessing | AppActionCallFailed)

Expand Down Expand Up @@ -94,8 +95,8 @@ export interface AppActionCallRawResponseProps {

export interface AppActionCallResponseData
extends AppActionCallResponse,
DefaultElements<AppActionCallResponse>,
AppActionCallApi {}
DefaultElements<AppActionCallResponse>,
AppActionCallApi { }

export type AppActionCall = AppActionCallProps & DefaultElements<AppActionCallProps>

Expand Down
14 changes: 4 additions & 10 deletions lib/entities/app-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import copy from 'fast-copy'
import type { Except } from 'type-fest'
import { wrapCollection } from '../common-utils'
import type {
BasicMetaSysProps,
DefaultElements,
Link,
MakeRequest,
SysLink,
} from '../common-types'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import type { ParameterDefinition } from './widget-parameters'
import enhanceWithMethods from '../enhance-with-methods'

type AppActionSys = Except<BasicMetaSysProps, 'version'> & {
appDefinition: SysLink
organization: SysLink
type AppActionSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}

export type AppActionParameterDefinition = Omit<ParameterDefinition, 'labels'>
Expand Down
8 changes: 4 additions & 4 deletions lib/entities/app-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import copy from 'fast-copy'
import type { Except } from 'type-fest'
import { wrapCollection } from '../common-utils'
import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

type AppBundleSys = Except<BasicMetaSysProps, 'version'> & {
appDefinition: SysLink
organization: SysLink
type AppBundleSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}

interface ActionManifestProps {
Expand Down
Loading
Loading