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
4 changes: 2 additions & 2 deletions lib/adapters/REST/endpoints/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getManyForSpace: RestEndpoint<'Usage', 'getManyForSpace'> = (
http: AxiosInstance,
params: { organizationId: string } & QueryParams
) => {
return raw.get<CollectionProp<UsageProps>>(
return raw.get<CollectionProp<UsageProps<'SpacePeriodicUsage'>>>(
http,
`/organizations/${params.organizationId}/space_periodic_usages`,
{
Expand All @@ -21,7 +21,7 @@ export const getManyForOrganization: RestEndpoint<'Usage', 'getManyForOrganizati
http: AxiosInstance,
params: { organizationId: string } & QueryParams
) => {
return raw.get<CollectionProp<UsageProps>>(
return raw.get<CollectionProp<UsageProps<'OrganizationPeriodicUsage'>>>(
http,
`/organizations/${params.organizationId}/organization_periodic_usages`,
{
Expand Down
8 changes: 4 additions & 4 deletions lib/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export interface SpaceQueryOptions extends PaginationQueryOptions {
spaceId?: string
}

export interface BasicMetaSysProps<TSubject extends string = string> {
type: string
export interface BasicMetaSysProps<TType extends string, TSubject extends string = string> {
type: TType
id: string
version: number
createdBy?: { [Subject in TSubject]: Link<Subject> }[TSubject]
Expand All @@ -258,8 +258,8 @@ export interface BasicMetaSysProps<TSubject extends string = string> {
updatedAt: string
}

export interface MetaSysProps<TSubject extends string = string>
extends BasicMetaSysProps<TSubject> {
export interface MetaSysProps<TType extends string, TSubject extends string = string>
extends BasicMetaSysProps<TType, TSubject> {
space?: Link<'Space'>
/**
* @deprecated `status` only exists on entities. Please refactor to use a
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Application = {
sys: Link<'Application'>
}

type AccessTokenSysProps = BasicMetaSysProps<'User'> & {
type AccessTokenSysProps = BasicMetaSysProps<'PersonalAccessToken', 'User'> & {
application: Application | null
expiresAt: string | null
lastUsedAt: string | null
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/ai-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface AiActionQueryOptions {
}

export type AiActionProps = {
sys: MetaSysProps<'User' | 'AppDefinition'> & {
sys: MetaSysProps<'AiAction', 'User' | 'AppDefinition'> & {
type: 'AiAction'
space: Link<'Space'>
publishedBy?: Link<'User'> | Link<'AppDefinition'>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { freezeSys, toPlainObject } from 'contentful-sdk-core'
import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'

type AppAccessTokenSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
type AppAccessTokenSys = Except<BasicMetaSysProps<'AppAccessToken', 'User'>, 'version' | 'id'> & {
space: Link<'Space'>
environment: Link<'Environment'>
appDefinition: Link<'AppDefinition'>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-action-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
import type { WebhookCallDetailsProps } from './webhook'
import enhanceWithMethods from '../enhance-with-methods'

type AppActionCallSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
type AppActionCallSys = Except<BasicMetaSysProps<'AppActionCall', 'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
space: Link<'Space'>
environment: Link<'Environment'>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../c
import type { ParameterDefinition } from './widget-parameters'
import enhanceWithMethods from '../enhance-with-methods'

type AppActionSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
type AppActionSys = Except<BasicMetaSysProps<'AppAction', 'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { wrapCollection } from '../common-utils'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

type AppBundleSys = Except<BasicMetaSysProps<'User'>, 'version'> & {
type AppBundleSys = Except<BasicMetaSysProps<'AppBundle', 'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type AppDefinitionProps = {
/**
* System metadata
*/
sys: BasicMetaSysProps<'User'> & {
sys: BasicMetaSysProps<'AppDefinition', 'User'> & {
organization: Link<'Organization'>
shared: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

type AppDetailsSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
type AppDetailsSys = Except<BasicMetaSysProps<'AppDetails', 'User'>, 'version' | 'id'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
5 changes: 4 additions & 1 deletion lib/entities/app-event-subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

type AppEventSubscriptionSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
type AppEventSubscriptionSys = Except<
BasicMetaSysProps<'AppEventSubscription', 'User'>,
'version' | 'id'
> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Except } from 'type-fest'
import type { FreeFormParameters } from './widget-parameters'

export type AppInstallationProps = {
sys: Omit<BasicMetaSysProps<'User'>, 'id'> & {
sys: Omit<BasicMetaSysProps<'AppInstallation', 'User'>, 'id'> & {
appDefinition: Link<'AppDefinition'>
environment: Link<'Environment'>
space: Link<'Space'>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../c
import enhanceWithMethods from '../enhance-with-methods'
import { wrapCollection } from '../common-utils'

type AppKeySys = Except<BasicMetaSysProps<'User'>, 'version'> & {
type AppKeySys = Except<BasicMetaSysProps<'AppKey', 'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
5 changes: 4 additions & 1 deletion lib/entities/app-signed-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { toPlainObject } from 'contentful-sdk-core'
import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'

type AppSignedRequestSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
type AppSignedRequestSys = Except<
BasicMetaSysProps<'AppSignedRequest', 'User'>,
'version' | 'id'
> & {
appDefinition: Link<'AppDefinition'>
space: Link<'Space'>
environment: Link<'Environment'>
Expand Down
5 changes: 4 additions & 1 deletion lib/entities/app-signing-secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { Except } from 'type-fest'
import type { BasicMetaSysProps, DefaultElements, Link, MakeRequest } from '../common-types'
import enhanceWithMethods from '../enhance-with-methods'

type AppSigningSecretSys = Except<BasicMetaSysProps<'User'>, 'version' | 'id'> & {
type AppSigningSecretSys = Except<
BasicMetaSysProps<'AppSigningSecret', 'User'>,
'version' | 'id'
> & {
appDefinition: Link<'AppDefinition'>
organization: Link<'Organization'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/app-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { BasicMetaSysProps, DefaultElements, MakeRequest, Link } from '../c
import { wrapCollection } from '../common-utils'
import enhanceWithMethods from '../enhance-with-methods'

type AppUploadSys = Except<BasicMetaSysProps<'User'>, 'version'>
type AppUploadSys = Except<BasicMetaSysProps<'AppUpload', 'User'>, 'version'>

export type AppUploadProps = {
sys: AppUploadSys & {
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface LinkWithReference<T extends string> extends Link<T> {
}

export type CommentSysProps = Pick<
BasicMetaSysProps<'User'>,
BasicMetaSysProps<'Comment', 'User'>,
'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'
> & {
type: 'Comment'
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/content-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type AnnotationAssignment = Link<'Annotation'> & {
}

export type ContentTypeProps = {
sys: BasicMetaSysProps<'User' | 'AppDefinition'> & {
sys: BasicMetaSysProps<'ContentType', 'User' | 'AppDefinition'> & {
space: Link<'Space'>
environment: Link<'Environment'>
firstPublishedAt?: string
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/environment-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type EnvironmentAliasProps = {
/**
* System meta data
*/
sys: BasicMetaSysProps<'User'> & { space: Link<'Space'> }
sys: BasicMetaSysProps<'EnvironmentAlias', 'User'> & { space: Link<'Space'> }
environment: Link<'Environment'>
}

Expand Down
2 changes: 1 addition & 1 deletion lib/entities/environment-template-installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type EnvironmentTemplateInstallationStatus =
keyof typeof EnvironmentTemplateInstallationStatuses

export type EnvironmentTemplateInstallationProps = {
sys: BasicMetaSysProps<'User'> & {
sys: BasicMetaSysProps<'EnvironmentTemplateInstallation', 'User'> & {
type: 'EnvironmentTemplateInstallation'
space: Link<'Space'>
template: VersionedLink<'Template'>
Expand Down
5 changes: 4 additions & 1 deletion lib/entities/environment-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export interface ContentTypeTemplateProps extends Omit<ContentTypeProps, 'sys'>
}

export type EnvironmentTemplateProps = {
sys: BasicMetaSysProps<'User'> & { version: number; organization: Link<'Organization'> }
sys: BasicMetaSysProps<'EnvironmentTemplate', 'User'> & {
version: number
organization: Link<'Organization'>
}
name: string
description?: string
versionName: string
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import createEnvironmentApi from '../create-environment-api'
import { wrapCollection } from '../common-utils'
import type { DefaultElements, BasicMetaSysProps, MakeRequest, Link } from '../common-types'

type EnvironmentMetaSys = BasicMetaSysProps<'User'> & {
type EnvironmentMetaSys = BasicMetaSysProps<'EnvironmentMeta', 'User'> & {
status: Link<'Status'>
space: Link<'Space'>
aliases?: Array<Link<'EnvironmentAlias'>>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { wrapCollection } from '../common-utils'
import type { DefaultElements, BasicMetaSysProps, MakeRequest, Link } from '../common-types'
import type { SetRequired, RequireExactlyOne } from 'type-fest'

type ExtensionSysProps = BasicMetaSysProps<'User'> & {
type ExtensionSysProps = BasicMetaSysProps<'Extension', 'User'> & {
space: Link<'Space'>
environment: Link<'Environment'>
srcdocSha256?: string
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { wrapCollection } from '../common-utils'
import type { BasicMetaSysProps, DefaultElements, MakeRequest, Link } from '../common-types'

export type LocaleProps = {
sys: BasicMetaSysProps<'User' | 'AppDefinition'> & {
sys: BasicMetaSysProps<'Locale', 'User' | 'AppDefinition'> & {
space: Link<'Space'>
environment: Link<'Environment'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/oauth-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import enhanceWithMethods from '../enhance-with-methods'
import copy from 'fast-copy'
import { wrapCursorPaginatedCollection } from '../common-utils'

type OAuthApplicationSysProps = BasicMetaSysProps<'User'> & {
type OAuthApplicationSysProps = BasicMetaSysProps<'Application', 'User'> & {
lastUsedAt: string | null
}

Expand Down
2 changes: 1 addition & 1 deletion lib/entities/resource-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ResourceProviderProps = {
/**
* System metadata
*/
sys: Omit<BasicMetaSysProps<'User'>, 'version'> & {
sys: Omit<BasicMetaSysProps<'ResourceProvider', 'User'>, 'version'> & {
organization: Link<'Organization'>
appDefinition: Link<'AppDefinition'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/resource-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ResourceTypeProps = {
/**
* System metadata
*/
sys: Omit<BasicMetaSysProps<'User'>, 'version'> & {
sys: Omit<BasicMetaSysProps<'ResourceType', 'User'>, 'version'> & {
appDefinition: Link<'AppDefinition'>
resourceProvider: Link<'ResourceProvider'>
organization: Link<'Organization'>
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type ConstraintType = {
}

export type RoleProps = {
sys: BasicMetaSysProps<'User'> & { space: Link<'Space'> }
sys: BasicMetaSysProps<'Role', 'User'> & { space: Link<'Space'> }
name: string
description?: string
/**
Expand Down
5 changes: 4 additions & 1 deletion lib/entities/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import createSpaceApi from '../create-space-api'
import enhanceWithMethods from '../enhance-with-methods'

export type SpaceProps = {
sys: BasicMetaSysProps<'User'> & { organization: { sys: { id: string } }; archivedAt?: string }
sys: BasicMetaSysProps<'Space', 'User'> & {
organization: { sys: { id: string } }
archivedAt?: string
}
name: string
}

Expand Down
2 changes: 1 addition & 1 deletion lib/entities/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import enhanceWithMethods from '../enhance-with-methods'
export type TaskStatus = 'active' | 'resolved'

export type TaskSysProps = Pick<
BasicMetaSysProps<'User' | 'AppDefinition'>,
BasicMetaSysProps<'Task', 'User' | 'AppDefinition'>,
'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'
> & {
type: 'Task'
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/ui-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type UIConfigProps = {
publish?: { publishMode: 'entryPublishing' | 'localePublishing' }
}

export interface UIConfigSysProps extends BasicMetaSysProps<'User' | 'AppDefinition'> {
export interface UIConfigSysProps extends BasicMetaSysProps<'UIConfig', 'User' | 'AppDefinition'> {
space: Link<'Space'>
environment: Link<'Environment'>
}
Expand Down
8 changes: 6 additions & 2 deletions lib/entities/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ export interface UsageQuery extends QueryOptions {
'dateRange.endAt'?: string
}

export type UsageProps = {
export type UsageProps<
TType extends 'SpacePeriodicUsage' | 'OrganizationPeriodicUsage' =
| 'SpacePeriodicUsage'
| 'OrganizationPeriodicUsage'
> = {
/**
* System metadata
*/
sys: {
id: string
type: string
type: TType
organization?: Link<'Organization'>
}

Expand Down
3 changes: 2 additions & 1 deletion lib/entities/user-ui-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export type UserUIConfigProps = {
entryListViews: ViewFolder[]
}

export interface UserUIConfigSysProps extends BasicMetaSysProps<'User' | 'AppDefinition'> {
export interface UserUIConfigSysProps
extends BasicMetaSysProps<'UserUIConfig', 'User' | 'AppDefinition'> {
space: Link<'Space'>
environment: Link<'Environment'>
}
Expand Down
2 changes: 1 addition & 1 deletion lib/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type UserProps = {
/**
* System metadata
*/
sys: BasicMetaSysProps<'User'>
sys: BasicMetaSysProps<'User', 'User'>

/**
* First name of the user
Expand Down
Loading