Skip to content

Commit

Permalink
Merge pull request #639 from contentful/feat/expose-tags-api
Browse files Browse the repository at this point in the history
feat: expose tags api
  • Loading branch information
damienxy authored Apr 6, 2021
2 parents 3dcfcf8 + 47cf06b commit 4c7881c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const spaceMethods: Array<keyof SpaceAPI> = [
'getEntityScheduledActions',

'signRequest',

'createTag',
'readTags',
'updateTag',
'deleteTag',
]

export default function createSpace(
Expand Down
24 changes: 23 additions & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type EntityType = 'Entry' | 'Asset'
export type TagVisibility = 'private' | 'public'

export interface SpaceMembership {
sys: {
Expand Down Expand Up @@ -30,11 +31,27 @@ export interface Items {
export interface Link {
sys: {
id: string
type: string
type: 'Link'
linkType: string
}
}

export interface Tag {
sys: {
type: 'Tag'
id: string
space: Link
environment: Link
createdBy: Link
updatedBy: Link
createdAt: string
updatedAt: string
version: number
visibility: 'private' | 'public'
}
name: string
}

export type CollectionResponse<T> = {
items: T[]
total: number
Expand Down Expand Up @@ -375,6 +392,11 @@ export interface SpaceAPI {
getAllScheduledActions: () => Promise<ScheduledAction[]>

signRequest: (request: CanonicalRequest) => Promise<Record<string, string>>

createTag: (id: string, name: string, visibility?: TagVisibility) => Promise<Tag>
readTags: (skip: number, limit: number) => Promise<CollectionResponse<Tag>>
updateTag: (id: string, name: string, version: number) => Promise<Tag>
deleteTag: (id: string, version: number) => Promise<boolean>
}

/* Locales API */
Expand Down
5 changes: 5 additions & 0 deletions test/unit/space.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const spaceMethods = [
'getUsers',

'signRequest',

'createTag',
'readTags',
'updateTag',
'deleteTag',
]

describe('createSpace()', () => {
Expand Down

0 comments on commit 4c7881c

Please sign in to comment.