Skip to content
Draft
Show file tree
Hide file tree
Changes from 11 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
157 changes: 71 additions & 86 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 @@ -1336,50 +1321,50 @@ export type MRActions = {
}
Comment: {
get:
| { params: GetCommentParams & PlainTextBodyFormat; return: CommentProps }
| { params: GetCommentParams & RichTextBodyFormat; return: RichTextCommentProps }
| { params: GetCommentParams & PlainTextBodyFormat; return: CommentProps }
| { params: GetCommentParams & RichTextBodyFormat; return: RichTextCommentProps }
getMany:
| {
params: GetManyCommentsParams & PlainTextBodyFormat & QueryParams
return: CollectionProp<CommentProps>
}
| {
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
| {
params: GetManyCommentsParams & PlainTextBodyFormat & QueryParams
return: CollectionProp<CommentProps>
}
| {
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
getAll:
| {
params: GetManyCommentsParams & QueryParams & PlainTextBodyFormat
return: CollectionProp<CommentProps>
}
| {
params: GetManyCommentsParams & QueryParams & RichTextBodyFormat
return: CollectionProp<RichTextCommentProps>
}
| {
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 & PlainTextBodyFormat
payload: CreateCommentProps
return: CommentProps
}
| {
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
}
| {
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 @@ -2385,18 +2370,18 @@ export type MROpts<
} & (UA extends true ? { userAgent: string } : {}) &
('params' extends keyof MRActions[ET][Action]
? undefined extends MRActions[ET][Action]['params']
? { params?: MRActions[ET][Action]['params'] }
: { params: MRActions[ET][Action]['params'] }
? { params?: MRActions[ET][Action]['params'] }
: { params: MRActions[ET][Action]['params'] }
: {}) &
('payload' extends keyof MRActions[ET][Action]
? undefined extends MRActions[ET][Action]['payload']
? { payload?: MRActions[ET][Action]['payload'] }
: { payload: MRActions[ET][Action]['payload'] }
? { payload?: MRActions[ET][Action]['payload'] }
: { payload: MRActions[ET][Action]['payload'] }
: {}) &
('headers' extends keyof MRActions[ET][Action]
? undefined extends MRActions[ET][Action]['headers']
? { headers?: MRActions[ET][Action]['headers'] }
: { headers: MRActions[ET][Action]['headers'] }
? { headers?: MRActions[ET][Action]['headers'] }
: { headers: MRActions[ET][Action]['headers'] }
: {})

/**
Expand All @@ -2409,7 +2394,7 @@ export type MRReturn<

/** Base interface for all Payload interfaces. Used as part of the MakeRequestOptions to simplify payload definitions. */

export interface MakeRequestPayload {}
export interface MakeRequestPayload { }

export interface MakeRequestOptions {
entityType: keyof MRActions
Expand Down Expand Up @@ -2550,16 +2535,16 @@ export type GetConceptDescendantsParams = GetOrganizationParams & { conceptId: s
}
export type GetManyConceptParams = GetOrganizationParams & {
query?:
| { pageUrl?: string }
| ({ conceptScheme?: string; query?: string } & BasicCursorPaginationOptions &
Omit<PaginationQueryOptions, 'skip'>)
| { pageUrl?: string }
| ({ conceptScheme?: string; query?: string } & BasicCursorPaginationOptions &
Omit<PaginationQueryOptions, 'skip'>)
}

export type GetConceptSchemeParams = GetOrganizationParams & { conceptSchemeId: string }
export type GetManyConceptSchemeParams = GetOrganizationParams & {
query?:
| { pageUrl?: string }
| ({ query?: string } & BasicCursorPaginationOptions & Omit<PaginationQueryOptions, 'skip'>)
| { pageUrl?: string }
| ({ query?: string } & BasicCursorPaginationOptions & Omit<PaginationQueryOptions, 'skip'>)
}
export type DeleteConceptSchemeParams = GetOrganizationParams & {
conceptSchemeId: string
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
34 changes: 14 additions & 20 deletions lib/entities/ai-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export type ReferenceVariableConfiguration = {

export type VariableConfiguration =
| {
strict: boolean
in: Array<string>
}
strict: boolean
in: Array<string>
}
| ReferenceVariableConfiguration

export type Variable = {
Expand All @@ -49,17 +49,17 @@ export type Configuration = {

export type AiActionTestCase =
| {
type?: 'Text'
value?: string
}
type?: 'Text'
value?: string
}
| {
type?: 'Reference'
value?: {
entityPath?: string
entityType?: 'Entry'
entityId?: string
}
type?: 'Reference'
value?: {
entityPath?: string
entityType?: 'Entry'
entityId?: string
}
}

export interface AiActionQueryOptions {
limit?: number
Expand All @@ -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
Loading
Loading