Skip to content

Commit

Permalink
feat: expose automation tags on entry.sys [] (#1468)
Browse files Browse the repository at this point in the history
feat: expose automation tags on entry.sys
  • Loading branch information
jfctfl authored Feb 6, 2023
1 parent ce27d49 commit a5cde02
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Channel } from './channel'
import { MemoizedSignal } from './signal'
import { ContentEntitySys, EntryAPI, EntryFieldInfo, Metadata, TaskAPI } from './types'
import { EntryAPI, EntryFieldInfo, EntrySys, Metadata, TaskAPI } from './types'

const taskMethods: Array<keyof TaskAPI> = [
'getTask',
Expand All @@ -17,7 +17,7 @@ export default function createEntry(
createEntryField: Function
): EntryAPI {
let sys = entryData.sys
const sysChanged = new MemoizedSignal<[ContentEntitySys]>(sys)
const sysChanged = new MemoizedSignal<[EntrySys]>(sys)
let metadata = entryData.metadata
const metadataChanged = new MemoizedSignal<[Metadata | undefined]>(metadata)

Expand Down Expand Up @@ -52,7 +52,7 @@ export default function createEntry(
save() {
return channel.call<void>('callEntryMethod', 'save')
},
onSysChanged(handler: (sys: ContentEntitySys) => void) {
onSysChanged(handler: (sys: EntrySys) => void) {
return sysChanged.attach(handler)
},
fields: fieldInfo.reduce((acc: any, info: EntryFieldInfo) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/types/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { EntryAPI } from './entry.types'
import { SpaceAPI } from './space.types'
import { WindowAPI } from './window.types'
import { ContentEntitySys, Link, SerializedJSONValue } from './utils'
import { EntrySys, Link, SerializedJSONValue } from './utils'
import { FieldAPI } from './field-locale.types'
import { DialogsAPI } from './dialogs.types'
import { AppConfigAPI } from './app.types'
Expand Down Expand Up @@ -275,7 +275,7 @@ export interface ConnectMessage {
contentType: ContentTypeAPI
editorInterface?: EditorInterface
entry: {
sys: ContentEntitySys
sys: EntrySys
metadata?: Metadata
}
fieldInfo: EntryFieldInfo[]
Expand Down
6 changes: 3 additions & 3 deletions lib/types/entry.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata, Task } from './entities'
import { EntryFieldAPI } from './field.types'
import { CollectionResponse, ContentEntitySys, SearchQuery } from './utils'
import { CollectionResponse, EntrySys, SearchQuery } from './utils'

type TaskState = 'active' | 'resolved'

Expand All @@ -27,15 +27,15 @@ export interface TaskAPI {

export interface EntryAPI extends TaskAPI {
/** Returns sys for an entry. */
getSys: () => ContentEntitySys
getSys: () => EntrySys
/** Publish the entry */
publish: (options?: { skipUiValidation?: boolean }) => Promise<void>
/** Unpublish the entry */
unpublish: () => Promise<void>
/** Saves the current changes of the entry */
save: () => Promise<void>
/** Calls the callback with sys every time that sys changes. */
onSysChanged: (callback: (sys: ContentEntitySys) => void) => () => void
onSysChanged: (callback: (sys: EntrySys) => void) => () => void
/** Allows to control the values of all other fields in the current entry. */
fields: { [key: string]: EntryFieldAPI }
/**
Expand Down
1 change: 1 addition & 0 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type { SpaceAPI } from './space.types'
export type {
SearchQuery,
CollectionResponse,
EntrySys,
ContentEntitySys,
ContentEntityType,
Items,
Expand Down
7 changes: 6 additions & 1 deletion lib/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface CollectionResponse<T> {

export type ContentEntityType = 'Entry' | 'Asset'

export interface ContentEntitySys {
export type ContentEntitySys = {
space: Link
id: string
type: ContentEntityType
Expand All @@ -55,6 +55,11 @@ export interface ContentEntitySys {
contentType: Link
}

export interface EntrySys extends ContentEntitySys {
type: 'Entry'
automationTags: Link<'Tag'>[]
}

export interface Items {
type: string
linkType?: string
Expand Down

0 comments on commit a5cde02

Please sign in to comment.