Skip to content

Commit 16b15e2

Browse files
authored
fix: include typings in the release (#699)
* fix: include typings in the release * chore: tweak space api types to adhere to cma.js * refactor: Item -> Items * revert: old tags api * feat: export UserAPI
1 parent afd5922 commit 16b15e2

File tree

6 files changed

+48
-55
lines changed

6 files changed

+48
-55
lines changed

lib/types/api.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { NavigatorAPI } from './navigator.types'
1010
import { EntryFieldInfo, FieldInfo } from './field.types'
1111

1212
/* User API */
13-
interface UserAPI {
13+
export interface UserAPI {
1414
sys: {
1515
id: string
1616
type: string

lib/types/entities.ts

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ContentEntitySys, ContentEntityType, Items, Link, Metadata } from './utils'
22

3-
type TagVisibility = 'private' | 'public'
3+
export type TagVisibility = 'private' | 'public'
44

55
export interface User {
66
/**
@@ -53,8 +53,8 @@ export interface Tag {
5353
id: string
5454
space: Link
5555
environment: Link
56-
createdBy: Link
57-
updatedBy: Link
56+
createdBy?: Link
57+
updatedBy?: Link
5858
createdAt: string
5959
updatedAt: string
6060
version: number
@@ -114,13 +114,15 @@ export interface Task {
114114
sys: TaskSys
115115
}
116116

117-
const enum PublicActionStatus {
118-
Scheduled = 'scheduled',
119-
Succeeded = 'succeeded',
120-
Failed = 'failed',
121-
Canceled = 'canceled',
117+
export enum ScheduledActionStatuses {
118+
scheduled = 'scheduled',
119+
inProgress = 'inProgress',
120+
succeeded = 'succeeded',
121+
failed = 'failed',
122+
canceled = 'canceled',
122123
}
123-
124+
// WARNING: This is using 'keyof' which looks at the left hand name, not the right hand value
125+
type PublicActionStatus = keyof typeof ScheduledActionStatuses
124126
type ScheduledActionActionType = 'publish' | 'unpublish'
125127

126128
export interface ScheduledAction {
@@ -133,13 +135,7 @@ export interface ScheduledAction {
133135
/** ISO 8601 string */
134136
canceledAt?: string
135137
canceledBy?: Link
136-
space: {
137-
sys: {
138-
id: string
139-
linkType: 'Space'
140-
type: string
141-
}
142-
}
138+
space: Link
143139
status: PublicActionStatus
144140
}
145141
entity: {
@@ -149,44 +145,40 @@ export interface ScheduledAction {
149145
type: string
150146
}
151147
}
152-
environment: {
153-
sys: {
154-
id: string
155-
linkType: 'Environment'
156-
type: string
157-
}
158-
}
148+
environment?: Link
159149
scheduledFor: {
160150
/** ISO 8601 string */
161151
datetime: string
162152
}
163153
action: ScheduledActionActionType
164154
}
165155

166-
export interface ContentTypeField {
167-
disabled: boolean
156+
export interface ContentTypeField extends Items {
168157
id: string
169-
localized: boolean
170158
name: string
171-
omitted: boolean
172159
required: boolean
173-
type: string
174-
validations: Object[]
175-
linkType?: string
160+
localized: boolean
161+
disabled?: boolean
162+
omitted?: boolean
163+
deleted?: boolean
176164
items?: Items
165+
apiName?: string
177166
}
178167

179168
export interface ContentType {
180169
sys: {
181170
type: string
182171
id: string
183-
version?: number
184-
space?: Link
185-
environment?: Link
186-
createdAt?: string
172+
version: number
187173
createdBy?: Link
188-
updatedAt?: string
174+
createdAt: string
189175
updatedBy?: Link
176+
updatedAt: string
177+
space: Link
178+
environment: Link
179+
firstPublishedAt?: string
180+
publishedCounter?: number
181+
publishedVersion?: number
190182
}
191183
fields: ContentTypeField[]
192184
name: string

lib/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type {
1717
ParametersAPI,
1818
SharedEditorSDK,
1919
SidebarExtensionSDK,
20+
UserAPI,
2021
} from './api.types'
2122

2223
export type { AppConfigAPI, AppState } from './app.types'
@@ -39,6 +40,7 @@ export type {
3940
ScheduledAction,
4041
SpaceMembership,
4142
Tag,
43+
TagVisibility,
4244
Task,
4345
} from './entities'
4446

lib/types/space.types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import {
66
ContentType,
77
EditorInterface,
88
ScheduledAction,
9-
SearchQuery,
109
Tag,
11-
TagVisibility,
1210
User,
11+
TagVisibility,
1312
} from './entities'
14-
import { CollectionResponse, ContentEntityType, Link, WithOptionalSys } from './utils'
13+
import { CollectionResponse, ContentEntityType, Link, WithOptionalSys, SearchQuery } from './utils'
1514

1615
type Snapshot<T> = {
1716
sys: {
@@ -34,7 +33,7 @@ export interface SpaceAPI {
3433
getCachedContentTypes: () => ContentType[]
3534
getContentType: (id: string) => Promise<ContentType>
3635
getContentTypes: () => Promise<CollectionResponse<ContentType>>
37-
createContentType: (data: WithOptionalSys<ContentType>) => Promise<ContentType>
36+
createContentType: (data: ContentType) => Promise<ContentType>
3837
updateContentType: (data: ContentType) => Promise<ContentType>
3938
deleteContentType: (data: ContentType) => Promise<void>
4039

lib/types/utils.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ export type WithOptionalSys<Type extends { sys: unknown }> = Omit<Type, 'sys'> &
22
sys?: Type['sys']
33
}
44

5-
export interface Link<Type = string> {
5+
export interface Link<LinkType = string, Type = string> {
66
sys: {
77
id: string
8-
type: 'Link'
9-
linkType: Type
8+
type: Type
9+
linkType: LinkType
1010
}
1111
}
1212

@@ -18,7 +18,7 @@ export interface CollectionResponse<T> {
1818
sys: { type: string }
1919
}
2020

21-
export type ContentEntityType = 'Entry' | 'Asset'
21+
export type ContentEntityType = 'Entry' | 'Asset' | string
2222

2323
export interface ContentEntitySys {
2424
space: Link
@@ -27,22 +27,22 @@ export interface ContentEntitySys {
2727
createdAt: string
2828
updatedAt: string
2929
environment: Link
30-
publishedVersion: number
30+
publishedVersion?: number
3131
deletedVersion?: number
3232
archivedVersion?: number
33-
publishedAt: string
34-
firstPublishedAt: string
35-
createdBy: Link
36-
updatedBy: Link
37-
publishedCounter: number
33+
publishedAt?: string
34+
firstPublishedAt?: string
35+
createdBy?: Link
36+
updatedBy?: Link
37+
publishedCounter?: number
3838
version: number
39-
publishedBy: Link
39+
publishedBy?: Link
4040
contentType: Link
4141
}
4242

43-
export type Metadata = Partial<{
44-
tags: Link<'Tag'>[]
45-
}>
43+
export type Metadata = {
44+
tags: Link<'Tag', 'Link'>[]
45+
}
4646

4747
export interface Items {
4848
type: string

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"forceConsistentCasingInFileNames": true,
1111
"declaration": true
1212
},
13-
"include": ["lib"],
13+
"include": ["lib/**/*"],
1414
"exclude": ["test"]
1515
}

0 commit comments

Comments
 (0)