Skip to content
Merged
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 @@ -190,7 +190,7 @@ export const createWithId: RestEndpoint<'Asset', 'createWithId'> = (
export const createFromFiles: RestEndpoint<'Asset', 'createFromFiles'> = async (
http: AxiosInstance,
params: GetSpaceEnvironmentParams & { uploadTimeout?: number },
data: Omit<AssetFileProp, 'sys'>
data: AssetFileProp
) => {
const httpUpload = getUploadHttpClient(http, { uploadTimeout: params.uploadTimeout })

Expand Down
43 changes: 14 additions & 29 deletions lib/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,41 +248,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 @@ -291,26 +291,11 @@ export interface EntityMetaSysProps extends MetaSysProps {
fieldStatus?: { '*': Record<string, 'draft' | 'changed' | 'published'> }
}

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 Down Expand Up @@ -1237,7 +1222,7 @@ export type MRActions = {
}
createFromFiles: {
params: GetSpaceEnvironmentParams & { uploadTimeout?: number }
payload: Omit<AssetFileProp, 'sys'>
payload: AssetFileProp
return: AssetProps
}
processForAllLocales: {
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 @@ -1100,7 +1100,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 @@ -48,9 +48,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
22 changes: 4 additions & 18 deletions lib/entities/ai-action.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, MetaSysProps } from '../common-types'
import type { DefaultElements, Link, MakeRequest, MetaSysProps } from '../common-types'
import { wrapCollection } from '../common-utils'
import enhanceWithMethods from '../enhance-with-methods'
import {
Expand Down Expand Up @@ -71,33 +71,19 @@ export type AiActionTestCase =
}
}

export type SysLinkUserOrApp = {
sys: {
id: string
linkType: 'User' | 'App'
type: 'Link'
}
}

export interface AiActionQueryOptions {
limit?: number
skip?: number
status?: StatusFilter
}

export type AiActionProps = {
sys: MetaSysProps & {
sys: MetaSysProps<'User' | 'AppDefinition'> & {
type: 'AiAction'
space: { sys: { id: string } }
publishedBy?: SysLinkUserOrApp
updatedBy: SysLinkUserOrApp
createdBy: SysLinkUserOrApp
publishedVersion?: number
space: Link<'Space'>
publishedBy?: Link<'User'> | Link<'AppDefinition'>
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
12 changes: 6 additions & 6 deletions lib/entities/app-action-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import type {
BasicMetaSysProps,
CreateWithResponseParams,
DefaultElements,
Link,
MakeRequest,
SysLink,
} from '../common-types'
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'>
}

type RetryOptions = Pick<CreateWithResponseParams, 'retries' | 'retryInterval'>
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
12 changes: 3 additions & 9 deletions lib/entities/app-definition.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import copy from 'fast-copy'
import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import type {
DefaultElements,
BasicMetaSysProps,
SysLink,
MakeRequest,
Link,
} from '../common-types'
import type { DefaultElements, BasicMetaSysProps, MakeRequest, Link } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'
import { wrapCollection } from '../common-utils'
import type { ContentfulAppDefinitionAPI } from '../create-app-definition-api'
Expand Down Expand Up @@ -44,8 +38,8 @@ export type AppDefinitionProps = {
/**
* System metadata
*/
sys: BasicMetaSysProps & {
organization: SysLink
sys: BasicMetaSysProps<'User'> & {
organization: Link<'Organization'>
shared: boolean
}
/**
Expand Down
8 changes: 4 additions & 4 deletions lib/entities/app-details.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import copy from 'fast-copy'
import { 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'
import enhanceWithMethods from '../enhance-with-methods'

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

export type IconType = 'base64'
Expand Down
14 changes: 4 additions & 10 deletions lib/entities/app-event-subscription.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import copy from 'fast-copy'
import { toPlainObject } from 'contentful-sdk-core'
import type { Except } from 'type-fest'
import type {
BasicMetaSysProps,
DefaultElements,
Link,
MakeRequest,
SysLink,
} from '../common-types'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

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

export type AppEventSubscriptionProps = {
Expand Down
12 changes: 6 additions & 6 deletions lib/entities/app-installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { toPlainObject, freezeSys } from 'contentful-sdk-core'
import copy from 'fast-copy'
import enhanceWithMethods from '../enhance-with-methods'
import { wrapCollection } from '../common-utils'
import type { DefaultElements, BasicMetaSysProps, SysLink, MakeRequest } from '../common-types'
import type { DefaultElements, BasicMetaSysProps, MakeRequest, Link } from '../common-types'
import type { Except } from 'type-fest'
import type { FreeFormParameters } from './widget-parameters'

export type AppInstallationProps = {
sys: Omit<BasicMetaSysProps, 'id'> & {
appDefinition: SysLink
environment: SysLink
space: SysLink
organization: SysLink
sys: Omit<BasicMetaSysProps<'User'>, 'id'> & {
appDefinition: Link<'AppDefinition'>
environment: Link<'Environment'>
space: Link<'Space'>
organization: Link<'Organization'>
}
/**
* Free-form installation parameters (API limits stringified length to 32KB)
Expand Down
Loading